<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>API: button   button.js  (YUI Library)</title>
	<link rel="stylesheet" type="text/css" href="assets/api.css">
</head>

<body id="yahoo-com">
<div id="doc3" class="yui-t2">

	<div id="hd">
        <h1>Yahoo! UI Library</h1>
        <h3>Button&nbsp; <span class="subtitle">2.2.2</span></h3>
        <p>
        <a href="./index.html">Yahoo! UI Library</a> 
            &gt; <a href="./module_button.html">button</a>
                
                 &gt; button.js (source view) 
            </p>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">

                    <div id="srcout">
<div class="highlight" ><pre><span class="c">/**</span>
<span class="c">* @module button</span>
<span class="c">* @description &lt;p&gt;The Button Control enables the creation of rich, graphical </span>
<span class="c">* buttons that function like traditional HTML form buttons.  &lt;em&gt;Unlike&lt;/em&gt; </span>
<span class="c">* tradition HTML form buttons, buttons created with the Button Control can have </span>
<span class="c">* a label that is different from its value.  With the inclusion of the optional </span>
<span class="c">* &lt;a href=&quot;module_menu.html&quot;&gt;Menu Control&lt;/a&gt;, the Button Control can also be</span>
<span class="c">* used to create menu buttons and split buttons, controls that are not </span>
<span class="c">* available natively in HTML.  The Button Control can also be thought of as a </span>
<span class="c">* way to create more visually engaging implementations of the browser&#39;s </span>
<span class="c">* default radio-button and check-box controls.&lt;/p&gt;</span>
<span class="c">* &lt;p&gt;The Button Control supports the following types:&lt;/p&gt;</span>
<span class="c">* &lt;dl&gt;</span>
<span class="c">* &lt;dt&gt;button&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;Basic push button that can execute a user-specified command when </span>
<span class="c">* pressed.&lt;/dd&gt;</span>
<span class="c">* &lt;dt&gt;link&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;Navigates to a specified url when pressed.&lt;/dd&gt;</span>
<span class="c">* &lt;dt&gt;submit&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;Submits the parent form when pressed.&lt;/dd&gt;</span>
<span class="c">* &lt;dt&gt;reset&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;Resets the parent form when pressed.&lt;/dd&gt;</span>
<span class="c">* &lt;dt&gt;checkbox&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;Maintains a &quot;checked&quot; state that can be toggled on and off.&lt;/dd&gt;</span>
<span class="c">* &lt;dt&gt;radio&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;Maintains a &quot;checked&quot; state that can be toggled on and off.  Use with </span>
<span class="c">* the ButtonGroup class to create a set of controls that are mutually </span>
<span class="c">* exclusive; checking one button in the set will uncheck all others in </span>
<span class="c">* the group.&lt;/dd&gt;</span>
<span class="c">* &lt;dt&gt;menubutton&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;When pressed will show/hide a menu.&lt;/dd&gt;</span>
<span class="c">* &lt;dt&gt;splitbutton&lt;/dt&gt;</span>
<span class="c">* &lt;dd&gt;Can execute a user-specified command or display a menu when pressed.&lt;/dd&gt;</span>
<span class="c">* &lt;/dl&gt;</span>
<span class="c">* @title Button</span>
<span class="c">* @namespace YAHOO.widget</span>
<span class="c">* @requires yahoo, dom, element, event</span>
<span class="c">* @optional container, menu</span>
<span class="c">* @beta</span>
<span class="c">*/</span>


<span class="o">(</span><span class="k">function</span><span class="o">()</span> <span class="o">{</span>

<span class="c">// Shorthard for utilities</span>
<span class="c"></span>
<span class="k">var</span> <span class="nx">Dom</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span>
    <span class="nx">Event</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">,</span>
    <span class="nx">Lang</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">lang</span><span class="o">,</span>


    <span class="c">// Private member variables</span>
<span class="c"></span>
    <span class="nx">m_oUserAgent</span> <span class="o">=</span> <span class="nx">navigator</span><span class="o">.</span><span class="nx">userAgent</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">(),</span>
    <span class="nx">m_bOpera</span> <span class="o">=</span> <span class="o">(</span><span class="nx">m_oUserAgent</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="s1">&#39;opera&#39;</span><span class="o">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">),</span>
    <span class="nx">m_bSafari</span> <span class="o">=</span> <span class="o">(</span><span class="nx">m_oUserAgent</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="s1">&#39;safari&#39;</span><span class="o">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">),</span>
    <span class="nx">m_bGecko</span> <span class="o">=</span> <span class="o">(!</span><span class="nx">m_bOpera</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">m_bSafari</span> <span class="o">&amp;&amp;</span> <span class="nx">m_oUserAgent</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="s1">&#39;gecko&#39;</span><span class="o">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">),</span>
    <span class="nx">m_bIE7</span> <span class="o">=</span> <span class="o">(!</span><span class="nx">m_bOpera</span> <span class="o">&amp;&amp;</span> <span class="nx">m_oUserAgent</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="s1">&#39;msie 7&#39;</span><span class="o">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">),</span>
    <span class="nx">m_bIE</span> <span class="o">=</span> <span class="o">(!</span><span class="nx">m_bOpera</span> <span class="o">&amp;&amp;</span> <span class="nx">m_oUserAgent</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="s1">&#39;msie&#39;</span><span class="o">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">),</span>
    <span class="nx">m_oButtons</span> <span class="o">=</span> <span class="o">{},</span>
    <span class="nx">m_oFocusedButton</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>



<span class="c">//  Constructor</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* The Button class creates a rich, graphical button.</span>
<span class="c">* @param {String} p_oElement String specifying the id attribute of the </span>
<span class="c">* &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt;, &lt;code&gt;&amp;#60;a&amp;#62;&lt;/code&gt; or </span>
<span class="c">* &lt;code&gt;&amp;#60;span&amp;#62;&lt;/code&gt; element to be used to create the button.</span>
<span class="c">* @param {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">* one-html.html#ID-6043025&quot;&gt;HTMLInputElement&lt;/a&gt;|&lt;a href=&quot;</span>
<span class="c">* http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#</span>
<span class="c">* ID-33759296&quot;&gt;HTMLElement&lt;/a&gt;} p_oElement Object reference for the </span>
<span class="c">* &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt;, &lt;code&gt;&amp;#60;a&amp;#62;&lt;/code&gt; or </span>
<span class="c">* &lt;code&gt;&amp;#60;span&amp;#62;&lt;/code&gt; element to be used to create the button.</span>
<span class="c">* @param {Object} p_oElement Object literal specifying a set of configuration  </span>
<span class="c">* attributes used to create the button.</span>
<span class="c">* @param {Object} p_oAttributes Optional. Object literal specifying a set of </span>
<span class="c">* configuration attributes used to create the button.</span>
<span class="c">* @namespace YAHOO.widget</span>
<span class="c">* @class Button</span>
<span class="c">* @constructor</span>
<span class="c">* @extends YAHOO.util.Element</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">,</span> <span class="nx">p_oAttributes</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">fnSuperClass</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">constructor</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span>
        <span class="nx">arguments</span><span class="o">.</span><span class="nx">length</span> <span class="o">==</span> <span class="m">1</span> <span class="o">&amp;&amp;</span> 
        <span class="o">!</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
        <span class="o">!</span><span class="nx">p_oElement</span><span class="o">.</span><span class="nx">nodeName</span>
    <span class="o">)</span> <span class="o">{</span>

        <span class="k">if</span><span class="o">(!</span><span class="nx">p_oElement</span><span class="o">.</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">generateId</span><span class="o">();</span>

            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span>
                <span class="s2">&quot;No value specified for the button&#39;s \&quot;id\&quot; attribute. &quot;</span> <span class="o">+</span>
                <span class="s2">&quot;Setting  button id to \&quot;&quot;</span> <span class="o">+</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;\&quot;.&quot;</span><span class="o">,</span>
                <span class="s2">&quot;warn&quot;</span>
            <span class="o">);</span>

        <span class="o">}</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">logger</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">LogWriter</span><span class="o">(</span><span class="s2">&quot;Button &quot;</span> <span class="o">+</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span>
                <span class="s2">&quot;No source HTML element.  &quot;</span>  <span class="o">+</span>
                <span class="s2">&quot;Building the button using the set of configuration attributes.&quot;</span>
            <span class="o">);</span>

        <span class="nx">fnSuperClass</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span>
            <span class="k">this</span><span class="o">,</span>
            <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_createButtonElement</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">.</span><span class="nx">type</span><span class="o">)),</span>
            <span class="nx">p_oElement</span>
        <span class="o">);</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oConfig</span> <span class="o">=</span> <span class="o">{</span>
        
            <span class="nx">element</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
            <span class="nx">attributes</span><span class="o">:</span> <span class="o">(</span><span class="nx">p_oAttributes</span> <span class="o">||</span> <span class="o">{})</span>
            
        <span class="o">},</span>

        <span class="nx">sTagName</span><span class="o">;</span>


        <span class="k">if</span><span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">))</span> <span class="o">{</span>

            <span class="k">var</span> <span class="nx">oElement</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">);</span>

            <span class="k">if</span> <span class="o">(</span><span class="nx">oElement</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">sTagName</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">();</span>
            
                <span class="k">if</span><span class="o">(</span><span class="nx">sTagName</span> <span class="o">==</span> <span class="k">this</span><span class="o">.</span><span class="nx">TAG_NAME</span><span class="o">)</span> <span class="o">{</span>
            
                    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
            
                <span class="o">}</span>
                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">sTagName</span> <span class="o">==</span> <span class="s2">&quot;INPUT&quot;</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
            
                    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">generateId</span><span class="o">();</span>
            
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span>
                        <span class="s2">&quot;No value specified for the button&#39;s \&quot;id\&quot; &quot;</span> <span class="o">+</span>
                        <span class="s2">&quot;attribute. Setting button id to \&quot;&quot;</span> <span class="o">+</span> 
                        <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;\&quot;.&quot;</span><span class="o">,</span>
                        <span class="s2">&quot;warn&quot;</span>
                    <span class="o">);</span>
                
                <span class="o">}</span>
            
                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">LogWriter</span><span class="o">(</span>
                                    <span class="s2">&quot;Button &quot;</span> <span class="o">+</span> <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span>
                                        <span class="o">);</span>
            
                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span>
                        <span class="s2">&quot;Building the button using an existing HTML &quot;</span> <span class="o">+</span> 
                        <span class="s2">&quot;element as a source element.&quot;</span> 
                    <span class="o">);</span>
            
            
                <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">srcelement</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">;</span>
            
                <span class="nx">initConfig</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">oConfig</span><span class="o">);</span>
            
            
                <span class="k">if</span><span class="o">(!</span><span class="nx">oConfig</span><span class="o">.</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
            
                    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span>
                            <span class="s2">&quot;Source element could not be used as is.  &quot;</span> <span class="o">+</span>
                            <span class="s2">&quot;Creating a new HTML element for the button.&quot;</span>
                        <span class="o">);</span>
            
                    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">element</span> <span class="o">=</span> 
                        <span class="k">this</span><span class="o">.</span><span class="nx">_createButtonElement</span><span class="o">(</span><span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">type</span><span class="o">);</span>
            
                <span class="o">}</span>
            
                <span class="nx">fnSuperClass</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">oConfig</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">);</span>

            <span class="o">}</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="nx">sTagName</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">();</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">sTagName</span> <span class="o">==</span> <span class="k">this</span><span class="o">.</span><span class="nx">TAG_NAME</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">if</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">.</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>

                    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
                
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>

                    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">generateId</span><span class="o">();</span>

                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span>
                        <span class="s2">&quot;No value specified for the button&#39;s \&quot;id\&quot; &quot;</span> <span class="o">+</span>
                        <span class="s2">&quot;attribute. Setting button id to \&quot;&quot;</span> <span class="o">+</span> 
                        <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;\&quot;.&quot;</span><span class="o">,</span>
                        <span class="s2">&quot;warn&quot;</span>
                    <span class="o">);</span>

                <span class="o">}</span>


            <span class="o">}</span>
            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">sTagName</span> <span class="o">==</span> <span class="s2">&quot;INPUT&quot;</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">generateId</span><span class="o">();</span>

                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span>
                    <span class="s2">&quot;No value specified for the button&#39;s \&quot;id\&quot; &quot;</span> <span class="o">+</span>
                    <span class="s2">&quot;attribute. Setting button id to \&quot;&quot;</span> <span class="o">+</span> 
                    <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;\&quot;.&quot;</span><span class="o">,</span>
                    <span class="s2">&quot;warn&quot;</span>
                <span class="o">);</span>
            
            <span class="o">}</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">logger</span> <span class="o">=</span> 
                <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">LogWriter</span><span class="o">(</span><span class="s2">&quot;Button &quot;</span> <span class="o">+</span> <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span>
                    <span class="s2">&quot;Building the button using an existing HTML element as &quot;</span> <span class="o">+</span> 
                    <span class="s2">&quot;a source element.&quot;</span> 
                <span class="o">);</span>


            <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">srcelement</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">;</span>
    
            <span class="nx">initConfig</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">oConfig</span><span class="o">);</span>
    
    
            <span class="k">if</span><span class="o">(!</span><span class="nx">oConfig</span><span class="o">.</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span>
                        <span class="s2">&quot;Source element could not be used as is.  &quot;</span> <span class="o">+</span>
                        <span class="s2">&quot;Creating a new HTML element for the button.&quot;</span>
                    <span class="o">);</span>
        
                <span class="nx">oConfig</span><span class="o">.</span><span class="nx">element</span> <span class="o">=</span> 
                    <span class="k">this</span><span class="o">.</span><span class="nx">_createButtonElement</span><span class="o">(</span><span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">.</span><span class="nx">type</span><span class="o">);</span>
        
            <span class="o">}</span>
        
            <span class="nx">fnSuperClass</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">oConfig</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="nx">oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">);</span>
        
        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">};</span>



<span class="c">// Private methods</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* @method getFirstElement</span>
<span class="c">* @description Returns an HTML element&#39;s first HTML element node.</span>
<span class="c">* @private</span>
<span class="c">* @param {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">* level-one-html.html#ID-58190037&quot;&gt;HTMLElement&lt;/a&gt;} p_oElement Object </span>
<span class="c">* reference specifying the element to be evaluated.</span>
<span class="c">* @return {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">* level-one-html.html#ID-58190037&quot;&gt;HTMLElement&lt;/a&gt;}</span>
<span class="c">*/</span>
<span class="k">function</span> <span class="nx">getFirstElement</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oFirstChild</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">firstChild</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oFirstChild</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">oFirstChild</span><span class="o">.</span><span class="nx">nodeType</span> <span class="o">==</span> <span class="m">1</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">return</span> <span class="nx">oFirstChild</span><span class="o">;</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="k">var</span> <span class="nx">oNextSibling</span> <span class="o">=</span> <span class="nx">oFirstChild</span><span class="o">.</span><span class="nx">nextSibling</span><span class="o">;</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">oNextSibling</span> <span class="o">&amp;&amp;</span> <span class="nx">oNextSibling</span><span class="o">.</span><span class="nx">nodeType</span> <span class="o">==</span> <span class="m">1</span><span class="o">)</span> <span class="o">{</span>
            
                <span class="k">return</span> <span class="nx">oNextSibling</span><span class="o">;</span>
            
            <span class="o">}</span>

        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">}</span>


<span class="c">/**</span>
<span class="c">* @method createInputElement</span>
<span class="c">* @description Creates an &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; element of the </span>
<span class="c">* specified type.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String specifying the type of </span>
<span class="c">* &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; element to create.</span>
<span class="c">* @param {String} p_sName String specifying the name of </span>
<span class="c">* &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; element to create.</span>
<span class="c">* @param {String} p_sValue String specifying the value of </span>
<span class="c">* &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; element to create.</span>
<span class="c">* @param {String} p_bChecked Boolean specifying if the  </span>
<span class="c">* &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; element is to be checked.</span>
<span class="c">* @return {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">* one-html.html#ID-6043025&quot;&gt;HTMLInputElement&lt;/a&gt;}</span>
<span class="c">*/</span>
<span class="k">function</span> <span class="nx">createInputElement</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_sName</span><span class="o">,</span> <span class="nx">p_sValue</span><span class="o">,</span> <span class="nx">p_bChecked</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oInput</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">m_bIE</span><span class="o">)</span> <span class="o">{</span>

        <span class="c">/*</span>
<span class="c">            For IE it is necessary to create the element with the </span>
<span class="c">            &quot;type,&quot; &quot;name,&quot; &quot;value,&quot; and &quot;checked&quot; properties set all at once.</span>
<span class="c">        */</span>
    
        <span class="k">var</span> <span class="nx">sInput</span> <span class="o">=</span> <span class="s2">&quot;&lt;input type=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">p_sType</span> <span class="o">+</span> <span class="s2">&quot;\&quot; name=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">p_sName</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&quot;</span><span class="o">;</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">p_bChecked</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">sInput</span> <span class="o">+=</span> <span class="s2">&quot; checked&quot;</span><span class="o">;</span>
        
        <span class="o">}</span>
        
        <span class="nx">sInput</span> <span class="o">+=</span> <span class="s2">&quot;&gt;&quot;</span><span class="o">;</span>

        <span class="nx">oInput</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="nx">sInput</span><span class="o">);</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
    
        <span class="nx">oInput</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;input&quot;</span><span class="o">);</span>
        <span class="nx">oInput</span><span class="o">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">p_sName</span><span class="o">;</span>
        <span class="nx">oInput</span><span class="o">.</span><span class="nx">type</span> <span class="o">=</span> <span class="nx">p_sType</span><span class="o">;</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">p_bChecked</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oInput</span><span class="o">.</span><span class="nx">checked</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        
        <span class="o">}</span>

    <span class="o">}</span>

    <span class="nx">oInput</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">p_sValue</span><span class="o">;</span>
    
    <span class="k">return</span> <span class="nx">oInput</span><span class="o">;</span>

<span class="o">}</span>


<span class="c">/**</span>
<span class="c">* @method setAttributesFromSrcElement</span>
<span class="c">* @description Gets the values for all the attributes of the source element </span>
<span class="c">* (either &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; or &lt;code&gt;&amp;#60;a&amp;#62;&lt;/code&gt;) that map to</span>
<span class="c">* Button configuration attributes and sets them into a collection that is</span>
<span class="c">* passed to the Button constructor.</span>
<span class="c">* @private</span>
<span class="c">* @param {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">* one-html.html#ID-6043025&quot;&gt;HTMLInputElement&lt;/a&gt;|&lt;a href=&quot;http://www.w3.org/</span>
<span class="c">* TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-</span>
<span class="c">* 48250443&quot;&gt;HTMLAnchorElement&lt;/a&gt;} p_oElement Object reference to the HTML </span>
<span class="c">* element (either &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; or &lt;code&gt;&amp;#60;span&amp;#62;&lt;/code&gt;) </span>
<span class="c">* used to create the button.</span>
<span class="c">* @param {Object} p_oAttributes Object reference for the collection of </span>
<span class="c">* configuration attributes used to create the button.</span>
<span class="c">*/</span>
<span class="k">function</span> <span class="nx">setAttributesFromSrcElement</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">,</span> <span class="nx">p_oAttributes</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>

    <span class="c">/**</span>
<span class="c">    * @method setAttributeFromDOMAttribute</span>
<span class="c">    * @description Gets the value of the specified DOM attribute and sets it </span>
<span class="c">    * into the collection of configuration attributes used to configure </span>
<span class="c">    * the button.</span>
<span class="c">    * @private</span>
<span class="c">    * @param {String} p_sAttribute String representing the name of the </span>
<span class="c">    * attribute to retrieve from the DOM element.</span>
<span class="c">    */</span>
    <span class="k">function</span> <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="nx">p_sAttribute</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">if</span><span class="o">(</span> <span class="o">!(</span><span class="nx">p_sAttribute</span> <span class="k">in</span> <span class="nx">p_oAttributes</span><span class="o">)</span> <span class="o">)</span> <span class="o">{</span>

            <span class="c">/*</span>
<span class="c">                Need to use &quot;getAttributeNode&quot; instead of &quot;getAttribute&quot; </span>
<span class="c">                because using &quot;getAttribute,&quot; IE will return the innerText of </span>
<span class="c">                a &lt;code&gt;&amp;#60;button&amp;#62;&lt;/code&gt; for the value attribute rather </span>
<span class="c">                than the value of the &quot;value&quot; attribute.</span>
<span class="c">            */</span>
    
            <span class="k">var</span> <span class="nx">oAttribute</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">getAttributeNode</span><span class="o">(</span><span class="nx">p_sAttribute</span><span class="o">);</span>
    

            <span class="k">if</span><span class="o">(</span><span class="nx">oAttribute</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="s2">&quot;value&quot;</span> <span class="k">in</span> <span class="nx">oAttribute</span><span class="o">))</span> <span class="o">{</span>

                <span class="nx">me</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span>
                    <span class="s2">&quot;Setting attribute \&quot;&quot;</span> <span class="o">+</span> <span class="nx">p_sAttribute</span> <span class="o">+</span> <span class="s2">&quot;\&quot; using &quot;</span> <span class="o">+</span>
                    <span class="s2">&quot;source element&#39;s attribute value of \&quot;&quot;</span> <span class="o">+</span> 
                    <span class="nx">oAttribute</span><span class="o">.</span><span class="nx">value</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&quot;</span>
                <span class="o">);</span>

                <span class="nx">p_oAttributes</span><span class="o">[</span><span class="nx">p_sAttribute</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oAttribute</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>

            <span class="o">}</span>

        <span class="o">}</span>
    
    <span class="o">}</span>


    <span class="c">/**</span>
<span class="c">    * @method setFormElementProperties</span>
<span class="c">    * @description Gets the value of the attributes from the form element and </span>
<span class="c">    * sets them into the collection of configuration attributes used to </span>
<span class="c">    * configure the button.</span>
<span class="c">    * @private</span>
<span class="c">    */</span>
    <span class="k">function</span> <span class="nx">setFormElementProperties</span><span class="o">()</span> <span class="o">{</span>

        <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>

        <span class="k">if</span><span class="o">(</span> <span class="o">!(</span><span class="s2">&quot;disabled&quot;</span> <span class="k">in</span> <span class="nx">p_oAttributes</span><span class="o">)</span> <span class="o">)</span> <span class="o">{</span>

            <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">disabled</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">disabled</span><span class="o">;</span>

        <span class="o">}</span>

        <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="s2">&quot;name&quot;</span><span class="o">);</span>
        <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="s2">&quot;value&quot;</span><span class="o">);</span>
        <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">);</span>

    <span class="o">}</span>


    <span class="k">var</span> <span class="nx">sSrcElementTagName</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">();</span>


    <span class="k">if</span><span class="o">(</span> <span class="o">!(</span><span class="s2">&quot;label&quot;</span> <span class="k">in</span> <span class="nx">p_oAttributes</span><span class="o">)</span> <span class="o">)</span> <span class="o">{</span>

        <span class="c">// Set the &quot;label&quot; property</span>
<span class="c"></span>    
        <span class="k">var</span> <span class="nx">sText</span> <span class="o">=</span> <span class="nx">sSrcElementTagName</span> <span class="o">==</span> <span class="s2">&quot;INPUT&quot;</span> <span class="o">?</span> 
                        <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">value</span> <span class="o">:</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">innerHTML</span><span class="o">;</span>
    
    
        <span class="k">if</span><span class="o">(</span><span class="nx">sText</span> <span class="o">&amp;&amp;</span> <span class="nx">sText</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
            
            <span class="nx">p_oAttributes</span><span class="o">.</span><span class="k">label</span> <span class="o">=</span> <span class="nx">sText</span><span class="o">;</span>
            
        <span class="o">}</span> 

    <span class="o">}</span>


    <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="s2">&quot;tabindex&quot;</span><span class="o">);</span>
    <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="s2">&quot;accesskey&quot;</span><span class="o">);</span>


    <span class="nx">switch</span><span class="o">(</span><span class="nx">sSrcElementTagName</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="nx">case</span> <span class="s2">&quot;A&quot;</span><span class="o">:</span>
        
            <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">type</span> <span class="o">=</span> <span class="s2">&quot;link&quot;</span><span class="o">;</span>

            <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="s2">&quot;href&quot;</span><span class="o">);</span>
            <span class="nx">setAttributeFromDOMAttribute</span><span class="o">(</span><span class="s2">&quot;target&quot;</span><span class="o">);</span>

        <span class="k">break</span><span class="o">;</span>

        <span class="nx">case</span> <span class="s2">&quot;INPUT&quot;</span><span class="o">:</span>

            <span class="nx">setFormElementProperties</span><span class="o">();</span>

            <span class="k">if</span><span class="o">(</span> <span class="o">!(</span><span class="s2">&quot;checked&quot;</span> <span class="k">in</span> <span class="nx">p_oAttributes</span><span class="o">)</span> <span class="o">)</span> <span class="o">{</span>
    
                <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">checked</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">checked</span><span class="o">;</span>
    
            <span class="o">}</span>

        <span class="k">break</span><span class="o">;</span>

        <span class="nx">case</span> <span class="s2">&quot;BUTTON&quot;</span><span class="o">:</span>

            <span class="nx">setFormElementProperties</span><span class="o">();</span>

            <span class="k">var</span> <span class="nx">oRootNode</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">oRootNode</span><span class="o">,</span> <span class="s2">&quot;checked&quot;</span><span class="o">))</span> <span class="o">{</span>
            
                <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">checked</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
            
            <span class="o">}</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">oRootNode</span><span class="o">,</span> <span class="s2">&quot;disabled&quot;</span><span class="o">))</span> <span class="o">{</span>

                <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">disabled</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
            
            <span class="o">}</span>

            <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">removeAttribute</span><span class="o">(</span><span class="s2">&quot;name&quot;</span><span class="o">);</span>
            <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">removeAttribute</span><span class="o">(</span><span class="s2">&quot;value&quot;</span><span class="o">);</span>

            <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">,</span> <span class="s2">&quot;button&quot;</span><span class="o">);</span>

        <span class="k">break</span><span class="o">;</span>
    
    <span class="o">}</span>

<span class="o">}</span>


<span class="c">/**</span>
<span class="c">* @method initConfig</span>
<span class="c">* @description Initializes the set of configuration attributes that are used to  </span>
<span class="c">* instantiate the button.</span>
<span class="c">* @private</span>
<span class="c">* @param {Object} Object representing the button&#39;s set of </span>
<span class="c">* configuration attributes.</span>
<span class="c">*/</span>
<span class="k">function</span> <span class="nx">initConfig</span><span class="o">(</span><span class="nx">p_oConfig</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oAttributes</span> <span class="o">=</span> <span class="nx">p_oConfig</span><span class="o">.</span><span class="nx">attributes</span><span class="o">,</span>
        <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">srcelement</span><span class="o">,</span>
        <span class="nx">sSrcElementTagName</span> <span class="o">=</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">();</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">sSrcElementTagName</span> <span class="o">==</span> <span class="k">this</span><span class="o">.</span><span class="nx">TAG_NAME</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">p_oConfig</span><span class="o">.</span><span class="nx">element</span> <span class="o">=</span> <span class="nx">oSrcElement</span><span class="o">;</span>

        <span class="k">var</span> <span class="nx">oFirstChild</span> <span class="o">=</span> <span class="nx">getFirstElement</span><span class="o">(</span><span class="nx">p_oConfig</span><span class="o">.</span><span class="nx">element</span><span class="o">);</span>

        <span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">oFirstChild</span><span class="o">,</span> <span class="s2">&quot;first-child&quot;</span><span class="o">);</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">oFirstChild</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">var</span> <span class="nx">oButton</span> <span class="o">=</span> <span class="nx">getFirstElement</span><span class="o">(</span><span class="nx">oFirstChild</span><span class="o">);</span>


            <span class="k">if</span><span class="o">(</span><span class="nx">oButton</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">var</span> <span class="nx">sButtonTagName</span> <span class="o">=</span> <span class="nx">oButton</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">();</span>


                <span class="k">if</span><span class="o">(</span><span class="nx">sButtonTagName</span> <span class="o">==</span> <span class="s2">&quot;A&quot;</span> <span class="o">||</span> <span class="nx">sButtonTagName</span> <span class="o">==</span> <span class="s2">&quot;BUTTON&quot;</span><span class="o">)</span> <span class="o">{</span>

                    <span class="nx">setAttributesFromSrcElement</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span>
                            <span class="k">this</span><span class="o">,</span> 
                            <span class="nx">oButton</span><span class="o">,</span> 
                            <span class="nx">oAttributes</span>
                        <span class="o">);</span>
                
                <span class="o">}</span>
            
            <span class="o">}</span>

        <span class="o">}</span>
    
    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">sSrcElementTagName</span> <span class="o">==</span> <span class="s2">&quot;INPUT&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">setAttributesFromSrcElement</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">oSrcElement</span><span class="o">,</span> <span class="nx">oAttributes</span><span class="o">);</span>
    
    <span class="o">}</span>

<span class="o">}</span>


<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">extend</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Element</span><span class="o">,</span> <span class="o">{</span>


<span class="c">// Protected properties</span>
<span class="c"></span>

<span class="c">/** </span>
<span class="c">* @property _button</span>
<span class="c">* @description Object reference to the button&#39;s internal </span>
<span class="c">* &lt;code&gt;&amp;#60;a&amp;#62;&lt;/code&gt; or &lt;code&gt;&amp;#60;button&amp;#62;&lt;/code&gt; element.</span>
<span class="c">* @default null</span>
<span class="c">* @protected</span>
<span class="c">* @type &lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">* one-html.html#ID-48250443&quot;&gt;HTMLAnchorElement&lt;/a&gt;|&lt;a href=&quot;</span>
<span class="c">* http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-</span>
<span class="c">* 34812697&quot;&gt;HTMLButtonElement&lt;/a&gt;</span>
<span class="c">*/</span>
<span class="nx">_button</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/** </span>
<span class="c">* @property _menu</span>
<span class="c">* @description Object reference to the button&#39;s menu.</span>
<span class="c">* @default null</span>
<span class="c">* @protected</span>
<span class="c">* @type &lt;a href=&quot;YAHOO.widget.Menu.html&quot;&gt;YAHOO.widget.Menu&lt;/a&gt;</span>
<span class="c">*/</span>
<span class="nx">_menu</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/** </span>
<span class="c">* @property _hiddenField</span>
<span class="c">* @description Object reference to the &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; element </span>
<span class="c">* used when the button&#39;s parent form is submitted.</span>
<span class="c">* @default null</span>
<span class="c">* @protected</span>
<span class="c">* @type &lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">* one-html.html#ID-6043025&quot;&gt;HTMLInputElement&lt;/a&gt;</span>
<span class="c">*/</span>
<span class="nx">_hiddenField</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/** </span>
<span class="c">* @property _onclickAttributeValue</span>
<span class="c">* @description Object reference to the button&#39;s current value for the &quot;onclick&quot;</span>
<span class="c">* configuration attribute.</span>
<span class="c">* @default null</span>
<span class="c">* @protected</span>
<span class="c">* @type Object</span>
<span class="c">*/</span>
<span class="nx">_onclickAttributeValue</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>


<span class="c">/** </span>
<span class="c">* @property _activationKeyPressed</span>
<span class="c">* @description Boolean indicating if the key(s) that toggle the button&#39;s </span>
<span class="c">* &quot;active&quot; state have been pressed.</span>
<span class="c">* @default false</span>
<span class="c">* @protected</span>
<span class="c">* @type Boolean</span>
<span class="c">*/</span>
<span class="nx">_activationKeyPressed</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>


<span class="c">/** </span>
<span class="c">* @property _activationButtonPressed</span>
<span class="c">* @description Boolean indicating if the mouse button that toggles the button&#39;s</span>
<span class="c">* &quot;active&quot; state has been pressed.</span>
<span class="c">* @default false</span>
<span class="c">* @protected</span>
<span class="c">* @type Boolean</span>
<span class="c">*/</span>
<span class="nx">_activationButtonPressed</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>


<span class="c">/** </span>
<span class="c">* @property _hasKeyEventHandlers</span>
<span class="c">* @description Boolean indicating if the button&#39;s &quot;blur&quot;, &quot;keydown&quot; and </span>
<span class="c">* &quot;keyup&quot; event handlers are assigned</span>
<span class="c">* @default false</span>
<span class="c">* @protected</span>
<span class="c">* @type Boolean</span>
<span class="c">*/</span>
<span class="nx">_hasKeyEventHandlers</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>


<span class="c">/** </span>
<span class="c">* @property _hasMouseEventHandlers</span>
<span class="c">* @description Boolean indicating if the button&#39;s &quot;mouseout&quot; and &quot;mousedown&quot; </span>
<span class="c">* and &quot;mouseup&quot; event handlers are assigned</span>
<span class="c">* @default false</span>
<span class="c">* @protected</span>
<span class="c">* @type Boolean</span>
<span class="c">*/</span>
<span class="nx">_hasMouseEventHandlers</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>



<span class="c">// Constants</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* @property TAG_NAME</span>
<span class="c">* @description The name of the tag to be used for the button&#39;s root element. </span>
<span class="c">* @default &quot;SPAN&quot;</span>
<span class="c">* @final</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">TAG_NAME</span><span class="o">:</span> <span class="s2">&quot;SPAN&quot;</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property CHECK_ACTIVATION_KEYS</span>
<span class="c">* @description Array of numbers representing keys that (when pressed) toggle </span>
<span class="c">* the button&#39;s &quot;checked&quot; attribute.</span>
<span class="c">* @default [32]</span>
<span class="c">* @final</span>
<span class="c">* @type Array</span>
<span class="c">*/</span>
<span class="nx">CHECK_ACTIVATION_KEYS</span><span class="o">:</span> <span class="o">[</span><span class="m">32</span><span class="o">],</span>


<span class="c">/**</span>
<span class="c">* @property ACTIVATION_KEYS</span>
<span class="c">* @description Array of numbers representing keys that (when presed) toggle </span>
<span class="c">* the button&#39;s &quot;active&quot; state.</span>
<span class="c">* @default [13, 32]</span>
<span class="c">* @final</span>
<span class="c">* @type Array</span>
<span class="c">*/</span>
<span class="nx">ACTIVATION_KEYS</span><span class="o">:</span> <span class="o">[</span><span class="m">13</span><span class="o">,</span> <span class="m">32</span><span class="o">],</span>


<span class="c">/**</span>
<span class="c">* @property OPTION_AREA_WIDTH</span>
<span class="c">* @description Width (in pixels) of the area of a split button that when </span>
<span class="c">* pressed will display a menu.</span>
<span class="c">* @default 20</span>
<span class="c">* @final</span>
<span class="c">* @type Number</span>
<span class="c">*/</span>
<span class="nx">OPTION_AREA_WIDTH</span><span class="o">:</span> <span class="m">20</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property CSS_CLASS_NAME</span>
<span class="c">* @description String representing the CSS class(es) to be applied to the </span>
<span class="c">* button&#39;s root element.</span>
<span class="c">* @default &quot;yuibutton&quot;</span>
<span class="c">* @final</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">CSS_CLASS_NAME</span><span class="o">:</span> <span class="s2">&quot;yuibutton&quot;</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property RADIO_DEFAULT_TITLE</span>
<span class="c">* @description String representing the default title applied to buttons of </span>
<span class="c">* type &quot;radio.&quot; </span>
<span class="c">* @default &quot;Unchecked.  Click to check.&quot;</span>
<span class="c">* @final</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">RADIO_DEFAULT_TITLE</span><span class="o">:</span> <span class="s2">&quot;Unchecked.  Click to check.&quot;</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property RADIO_CHECKED_TITLE</span>
<span class="c">* @description String representing the title applied to buttons of type &quot;radio&quot; </span>
<span class="c">* when checked.</span>
<span class="c">* @default &quot;Checked.  Click to uncheck.&quot;</span>
<span class="c">* @final</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">RADIO_CHECKED_TITLE</span><span class="o">:</span> <span class="s2">&quot;Checked.  Click to uncheck.&quot;</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property CHECKBOX_DEFAULT_TITLE</span>
<span class="c">* @description String representing the default title applied to buttons of </span>
<span class="c">* type &quot;checkbox.&quot; </span>
<span class="c">* @default &quot;Unchecked.  Click to check.&quot;</span>
<span class="c">* @final</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">CHECKBOX_DEFAULT_TITLE</span><span class="o">:</span> <span class="s2">&quot;Unchecked.  Click to check.&quot;</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property CHECKBOX_CHECKED_TITLE</span>
<span class="c">* @description String representing the title applied to buttons of type </span>
<span class="c">* &quot;checkbox&quot; when checked.</span>
<span class="c">* @default &quot;Checked.  Click to uncheck.&quot;</span>
<span class="c">* @final</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">CHECKBOX_CHECKED_TITLE</span><span class="o">:</span> <span class="s2">&quot;Checked.  Click to uncheck.&quot;</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property MENUBUTTON_DEFAULT_TITLE</span>
<span class="c">* @description String representing the default title applied to buttons of </span>
<span class="c">* type &quot;menubutton.&quot; </span>
<span class="c">* @default &quot;Menu collapsed.  Click to expand.&quot;</span>
<span class="c">* @final</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">MENUBUTTON_DEFAULT_TITLE</span><span class="o">:</span> <span class="s2">&quot;Menu collapsed.  Click to expand.&quot;</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property MENUBUTTON_MENU_VISIBLE_TITLE</span>
<span class="c">* @description String representing the title applied to buttons of type </span>
<span class="c">* &quot;menubutton&quot; when the button&#39;s menu is visible. </span>
<span class="c">* @default &quot;Menu expanded.  Click or press Esc to collapse.&quot;</span>
<span class="c">* @final</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">MENUBUTTON_MENU_VISIBLE_TITLE</span><span class="o">:</span> 
    <span class="s2">&quot;Menu expanded.  Click or press Esc to collapse.&quot;</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property SPLITBUTTON_DEFAULT_TITLE</span>
<span class="c">* @description  String representing the default title applied to buttons of </span>
<span class="c">* type &quot;splitebutton.&quot; </span>
<span class="c">* @default &quot;Menu collapsed.  Click inside option region or press </span>
<span class="c">* Ctrl + Shift + M to show the menu.&quot;</span>
<span class="c">* @final</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">SPLITBUTTON_DEFAULT_TITLE</span><span class="o">:</span> 
    <span class="s2">&quot;Menu collapsed.  Click inside option region or press Ctrl + Shift + M to show the menu.&quot;</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property SPLITBUTTON_OPTION_VISIBLE_TITLE</span>
<span class="c">* @description String representing the title applied to buttons of type </span>
<span class="c">* &quot;splitbutton&quot; when the button&#39;s menu is visible. </span>
<span class="c">* @default &quot;Menu expanded.  Press Esc or Ctrl + Shift + M to hide the menu.&quot;</span>
<span class="c">* @final</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">SPLITBUTTON_OPTION_VISIBLE_TITLE</span><span class="o">:</span> 
    <span class="s2">&quot;Menu expanded.  Press Esc or Ctrl + Shift + M to hide the menu.&quot;</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @property SUBMIT_TITLE</span>
<span class="c">* @description String representing the title applied to buttons of </span>
<span class="c">* type &quot;submit.&quot; </span>
<span class="c">* @default &quot;Click to submit form.&quot;</span>
<span class="c">* @final</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">SUBMIT_TITLE</span><span class="o">:</span> <span class="s2">&quot;Click to submit form.&quot;</span><span class="o">,</span>



<span class="c">// Protected attribute setter methods</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* @method _setType</span>
<span class="c">* @description Sets the value of the button&#39;s &quot;type&quot; attribute.</span>
<span class="c">* @protected</span>
<span class="c">* @param {String} p_sType String indicating the value for the button&#39;s </span>
<span class="c">* &quot;type&quot; attribute.</span>
<span class="c">*/</span>
<span class="nx">_setType</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">p_sType</span> <span class="o">==</span> <span class="s2">&quot;splitbutton&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;option&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onOption</span><span class="o">);</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _setLabel</span>
<span class="c">* @description Sets the value of the button&#39;s &quot;label&quot; attribute.</span>
<span class="c">* @protected</span>
<span class="c">* @param {String} p_sLabel String indicating the value for the button&#39;s </span>
<span class="c">* &quot;label&quot; attribute.</span>
<span class="c">*/</span>
<span class="nx">_setLabel</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sLabel</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">p_sLabel</span><span class="o">;</span>                

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _setTabIndex</span>
<span class="c">* @description Sets the value of the button&#39;s &quot;tabindex&quot; attribute.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Number} p_nTabIndex Number indicating the value for the button&#39;s </span>
<span class="c">* &quot;tabindex&quot; attribute.</span>
<span class="c">*/</span>
<span class="nx">_setTabIndex</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_nTabIndex</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">tabIndex</span> <span class="o">=</span> <span class="nx">p_nTabIndex</span><span class="o">;</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _setTitle</span>
<span class="c">* @description Sets the value of the button&#39;s &quot;title&quot; attribute.</span>
<span class="c">* @protected</span>
<span class="c">* @param {String} p_nTabIndex Number indicating the value for the button&#39;s </span>
<span class="c">* &quot;title&quot; attribute.</span>
<span class="c">*/</span>
<span class="nx">_setTitle</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sTitle</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="s2">&quot;link&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">sTitle</span> <span class="o">=</span> <span class="nx">p_sTitle</span><span class="o">;</span>

        <span class="k">if</span><span class="o">(!</span><span class="nx">sTitle</span><span class="o">)</span> <span class="o">{</span>


            <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>

            <span class="nx">switch</span><span class="o">(</span><span class="nx">sType</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">case</span> <span class="s2">&quot;radio&quot;</span><span class="o">:</span>

                    <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">RADIO_DEFAULT_TITLE</span><span class="o">;</span>

                <span class="k">break</span><span class="o">;</span>

                <span class="nx">case</span> <span class="s2">&quot;checkbox&quot;</span><span class="o">:</span>

                    <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">CHECKBOX_DEFAULT_TITLE</span><span class="o">;</span>

                <span class="k">break</span><span class="o">;</span>
                
                <span class="nx">case</span> <span class="s2">&quot;menubutton&quot;</span><span class="o">:</span>

                    <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">MENUBUTTON_DEFAULT_TITLE</span><span class="o">;</span>

                <span class="k">break</span><span class="o">;</span>

                <span class="nx">case</span> <span class="s2">&quot;splitbutton&quot;</span><span class="o">:</span>

                    <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">SPLITBUTTON_DEFAULT_TITLE</span><span class="o">;</span>

                <span class="k">break</span><span class="o">;</span>

                <span class="nx">case</span> <span class="s2">&quot;submit&quot;</span><span class="o">:</span>

                    <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">SUBMIT_TITLE</span><span class="o">;</span>

                <span class="k">break</span><span class="o">;</span>

            <span class="o">}</span>

        <span class="o">}</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">title</span> <span class="o">=</span> <span class="nx">sTitle</span><span class="o">;</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _setDisabled</span>
<span class="c">* @description Sets the value of the button&#39;s &quot;disabled&quot; attribute.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Boolean} p_bDisabled Boolean indicating the value for the button&#39;s </span>
<span class="c">* &quot;disabled&quot; attribute.</span>
<span class="c">*/</span>
<span class="nx">_setDisabled</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_bDisabled</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="s2">&quot;link&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">p_bDisabled</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">hasFocus</span><span class="o">())</span> <span class="o">{</span>
            
                <span class="k">this</span><span class="o">.</span><span class="nx">blur</span><span class="o">();</span>
            
            <span class="o">}</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">,</span> <span class="s2">&quot;disabled&quot;</span><span class="o">);</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">);</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">removeAttribute</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">);</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">);</span>
        
        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _setAccessKey</span>
<span class="c">* @description Sets the value of the button&#39;s &quot;accesskey&quot; attribute.</span>
<span class="c">* @protected</span>
<span class="c">* @param {String} p_sAccessKey String indicating the value for the button&#39;s </span>
<span class="c">* &quot;accesskey&quot; attribute.</span>
<span class="c">*/</span>
<span class="nx">_setAccessKey</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sAccessKey</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">accessKey</span> <span class="o">=</span> <span class="nx">p_sAccessKey</span><span class="o">;</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _setHref</span>
<span class="c">* @description Sets the value of the button&#39;s &quot;href&quot; attribute.</span>
<span class="c">* @protected</span>
<span class="c">* @param {String} p_sHref String indicating the value for the button&#39;s </span>
<span class="c">* &quot;href&quot; attribute.</span>
<span class="c">*/</span>
<span class="nx">_setHref</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sHref</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;link&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">href</span> <span class="o">=</span> <span class="nx">p_sHref</span><span class="o">;</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _setTarget</span>
<span class="c">* @description Sets the value of the button&#39;s &quot;target&quot; attribute.</span>
<span class="c">* @protected</span>
<span class="c">* @param {String} p_sTarget String indicating the value for the button&#39;s </span>
<span class="c">* &quot;target&quot; attribute.</span>
<span class="c">*/</span>
<span class="nx">_setTarget</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sTarget</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;link&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s2">&quot;target&quot;</span><span class="o">,</span> <span class="nx">p_sTarget</span><span class="o">);</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _setChecked</span>
<span class="c">* @description Sets the value of the button&#39;s &quot;target&quot; attribute.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Boolean} p_bChecked Boolean indicating the value for the button&#39;s </span>
<span class="c">* &quot;checked&quot; attribute.</span>
<span class="c">*/</span>
<span class="nx">_setChecked</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_bChecked</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">),</span>
        <span class="nx">sTitle</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">p_bChecked</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">);</span>
            
            <span class="nx">sTitle</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">?</span> 
                        <span class="k">this</span><span class="o">.</span><span class="nx">RADIO_CHECKED_TITLE</span> <span class="o">:</span> 
                        <span class="k">this</span><span class="o">.</span><span class="nx">CHECKBOX_CHECKED_TITLE</span><span class="o">;</span>
        
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">);</span>

            <span class="nx">sTitle</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">?</span> 
                        <span class="k">this</span><span class="o">.</span><span class="nx">RADIO_DEFAULT_TITLE</span> <span class="o">:</span> 
                        <span class="k">this</span><span class="o">.</span><span class="nx">CHECKBOX_DEFAULT_TITLE</span><span class="o">;</span>
        
        <span class="o">}</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">,</span> <span class="nx">sTitle</span><span class="o">);</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _setMenu</span>
<span class="c">* @description Sets the value of the button&#39;s &quot;menu&quot; attribute.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Object} p_oMenu Object indicating the value for the button&#39;s </span>
<span class="c">* &quot;menu&quot; attribute.</span>
<span class="c">*/</span>
<span class="nx">_setMenu</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">Menu</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Menu</span><span class="o">,</span>
        <span class="nx">oMenu</span><span class="o">,</span>
        <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(!</span><span class="nx">Menu</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;YAHOO.widget.Menu dependency not met.&quot;</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">);</span>

        <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
    
    <span class="o">}</span>


    <span class="k">function</span> <span class="nx">initMenu</span><span class="o">()</span> <span class="o">{</span>
    
        <span class="k">if</span><span class="o">(</span><span class="nx">oMenu</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="nx">oMenu</span><span class="o">.</span><span class="nx">showEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMenuShow</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
            <span class="nx">oMenu</span><span class="o">.</span><span class="nx">hideEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMenuHide</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
            <span class="nx">oMenu</span><span class="o">.</span><span class="nx">keyDownEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMenuKeyDown</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
            <span class="nx">oMenu</span><span class="o">.</span><span class="nx">renderEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMenuRender</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
            <span class="nx">oMenu</span><span class="o">.</span><span class="nx">clickEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMenuClick</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
            <span class="nx">oMenu</span><span class="o">.</span><span class="nx">itemAddedEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onMenuItemAdded</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

            <span class="k">var</span> <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">;</span>
    
            <span class="k">if</span><span class="o">(</span><span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;SELECT&quot;</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;none&quot;</span><span class="o">;</span>
                <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">oSrcElement</span><span class="o">);</span>
    
            <span class="o">}</span>
    
            <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">;</span>
    
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
    
            <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">destroy</span><span class="o">();</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
    
        <span class="o">}</span>
    
    <span class="o">}</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">p_oMenu</span> <span class="k">instanceof</span> <span class="nx">Menu</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">oMenu</span> <span class="o">=</span> <span class="nx">p_oMenu</span><span class="o">;</span>
        
        <span class="k">var</span> <span class="nx">aItems</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">getItems</span><span class="o">(),</span>
            <span class="nx">nItems</span> <span class="o">=</span> <span class="nx">aItems</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span>
            <span class="nx">oItem</span><span class="o">;</span>
    
        <span class="k">if</span><span class="o">(</span><span class="nx">nItems</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="nx">nItems</span> <span class="o">-</span> <span class="m">1</span><span class="o">;</span>
    
            <span class="k">do</span> <span class="o">{</span>
    
                <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">aItems</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
    
                <span class="k">if</span><span class="o">(</span><span class="nx">oItem</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">subscribeToConfigEvent</span><span class="o">(</span>
                                <span class="s2">&quot;selected&quot;</span><span class="o">,</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">_onMenuItemSelected</span><span class="o">,</span> 
                                <span class="nx">oItem</span><span class="o">,</span> 
                                <span class="k">this</span>
                            <span class="o">);</span>
    
                <span class="o">}</span>
            
            <span class="o">}</span>
            <span class="k">while</span><span class="o">(</span><span class="nx">i</span><span class="o">--);</span>
    
        <span class="o">}</span>

        <span class="nx">initMenu</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">))</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;appendTo&quot;</span><span class="o">,</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

            <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Menu</span><span class="o">(</span>
                            <span class="nx">Dom</span><span class="o">.</span><span class="nx">generateId</span><span class="o">(),</span> 
                            <span class="o">{</span> <span class="nx">lazyload</span><span class="o">:</span> <span class="kc">true</span><span class="o">,</span> <span class="nx">itemdata</span><span class="o">:</span> <span class="nx">p_oMenu</span> <span class="o">}</span>
                        <span class="o">);</span>
    
            <span class="nx">initMenu</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="nx">me</span><span class="o">);</span>
        
        <span class="o">});</span>
       
    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">))</span> <span class="o">{</span>

        <span class="nx">Event</span><span class="o">.</span><span class="nx">onContentReady</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">,</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

            <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Menu</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="o">{</span> <span class="nx">lazyload</span><span class="o">:</span> <span class="kc">true</span> <span class="o">});</span>

            <span class="nx">initMenu</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="nx">me</span><span class="o">);</span>
        
        <span class="o">});</span>
    
    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">p_oMenu</span> <span class="o">&amp;&amp;</span> <span class="nx">p_oMenu</span><span class="o">.</span><span class="nx">nodeName</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Menu</span><span class="o">(</span><span class="nx">p_oMenu</span><span class="o">,</span> <span class="o">{</span> <span class="nx">lazyload</span><span class="o">:</span> <span class="kc">true</span> <span class="o">});</span>
    
        <span class="nx">initMenu</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _setOnClick</span>
<span class="c">* @description Sets the value of the button&#39;s &quot;onclick&quot; attribute.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Object} p_oObject Object indicating the value for the button&#39;s </span>
<span class="c">* &quot;onclick&quot; attribute.</span>
<span class="c">*/</span>
<span class="nx">_setOnClick</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oObject</span><span class="o">)</span> <span class="o">{</span>

    <span class="c">/*</span>
<span class="c">        Remove any existing listeners if a &quot;click&quot; event handler has already </span>
<span class="c">        been specified.</span>
<span class="c">    */</span>

    <span class="k">if</span><span class="o">(</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_onclickAttributeValue</span> <span class="o">&amp;&amp;</span> 
        <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_onclickAttributeValue</span> <span class="o">!=</span> <span class="nx">p_oObject</span><span class="o">)</span>
    <span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onclickAttributeValue</span><span class="o">.</span><span class="nx">fn</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_onclickAttributeValue</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

    <span class="o">}</span>


    <span class="k">if</span><span class="o">(</span>
        <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">_onclickAttributeValue</span> <span class="o">&amp;&amp;</span> 
        <span class="nx">Lang</span><span class="o">.</span><span class="nx">isObject</span><span class="o">(</span><span class="nx">p_oObject</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
        <span class="nx">Lang</span><span class="o">.</span><span class="nx">isFunction</span><span class="o">(</span><span class="nx">p_oObject</span><span class="o">.</span><span class="nx">fn</span><span class="o">)</span>
    <span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="nx">p_oObject</span><span class="o">.</span><span class="nx">fn</span><span class="o">,</span> <span class="nx">p_oObject</span><span class="o">.</span><span class="nx">obj</span><span class="o">,</span> <span class="nx">p_oObject</span><span class="o">.</span><span class="nx">scope</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_onclickAttributeValue</span> <span class="o">=</span> <span class="nx">p_oObject</span><span class="o">;</span>

    <span class="o">}</span>

<span class="o">},</span>



<span class="c">// Protected methods</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* @method _createButtonElement</span>
<span class="c">* @description Creates the button&#39;s element.</span>
<span class="c">* @protected</span>
<span class="c">* @param {String} p_sType String indicating the type of element to create.</span>
<span class="c">* @return {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">* level-one-html.html#ID-58190037&quot;&gt;HTMLElement&lt;/a&gt;}</span>
<span class="c">*/</span>
<span class="nx">_createButtonElement</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">sTagName</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">TAG_NAME</span><span class="o">,</span>
        <span class="nx">oElement</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="nx">sTagName</span><span class="o">);</span>

    <span class="nx">oElement</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span>  
    
        <span class="s2">&quot;&lt;&quot;</span> <span class="o">+</span> <span class="nx">sTagName</span> <span class="o">+</span> <span class="s2">&quot; class=\&quot;first-child\&quot;&gt;&quot;</span> <span class="o">+</span> 
        <span class="o">(</span><span class="nx">p_sType</span> <span class="o">==</span> <span class="s2">&quot;link&quot;</span> <span class="o">?</span> <span class="s2">&quot;&lt;a&gt;&lt;/a&gt;&quot;</span> <span class="o">:</span> <span class="s2">&quot;&lt;button type=\&quot;button\&quot;&gt;&lt;/button&gt;&quot;</span><span class="o">)</span> <span class="o">+</span> 
        <span class="s2">&quot;&lt;/&quot;</span> <span class="o">+</span> <span class="nx">sTagName</span> <span class="o">+</span> <span class="s2">&quot;&gt;&quot;</span><span class="o">;</span>

    <span class="k">return</span> <span class="nx">oElement</span><span class="o">;</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _isActivationKey</span>
<span class="c">* @description Determines if the specified keycode is one that toggles the </span>
<span class="c">* button&#39;s &quot;active&quot; state.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Number} p_nKeyCode Number representing the keycode to be evaluated.</span>
<span class="c">* @return {Boolean}</span>
<span class="c">*/</span>
<span class="nx">_isActivationKey</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_nKeyCode</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">),</span>
        <span class="nx">aKeyCodes</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">?</span> 
            <span class="k">this</span><span class="o">.</span><span class="nx">CHECK_ACTIVATION_KEYS</span> <span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">ACTIVATION_KEYS</span><span class="o">,</span>

        <span class="nx">nKeyCodes</span> <span class="o">=</span> <span class="nx">aKeyCodes</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">nKeyCodes</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="nx">nKeyCodes</span> <span class="o">-</span> <span class="m">1</span><span class="o">;</span>

        <span class="k">do</span> <span class="o">{</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">p_nKeyCode</span> <span class="o">==</span> <span class="nx">aKeyCodes</span><span class="o">[</span><span class="nx">i</span><span class="o">])</span> <span class="o">{</span>

                <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>

            <span class="o">}</span>

        <span class="o">}</span>
        <span class="k">while</span><span class="o">(</span><span class="nx">i</span><span class="o">--);</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _isSplitButtonOptionKey</span>
<span class="c">* @description Determines if the specified keycode is one that toggles the </span>
<span class="c">* display of the split button&#39;s menu.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">* @return {Boolean}</span>
<span class="c">*/</span>
<span class="nx">_isSplitButtonOptionKey</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">return</span> <span class="o">(</span>
        <span class="nx">p_oEvent</span><span class="o">.</span><span class="nx">ctrlKey</span> <span class="o">&amp;&amp;</span> 
        <span class="nx">p_oEvent</span><span class="o">.</span><span class="nx">shiftKey</span> <span class="o">&amp;&amp;</span> 
        <span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">==</span> <span class="m">77</span>
    <span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _addListenersToForm</span>
<span class="c">* @description Adds event handlers to the button&#39;s form.</span>
<span class="c">* @protected</span>
<span class="c">*/</span>
<span class="nx">_addListenersToForm</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oForm</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getForm</span><span class="o">();</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oForm</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oForm</span><span class="o">,</span> <span class="s2">&quot;reset&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onFormReset</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
        <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oForm</span><span class="o">,</span> <span class="s2">&quot;submit&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onFormSubmit</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

        <span class="k">var</span> <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;srcelement&quot;</span><span class="o">);</span>


        <span class="k">if</span> <span class="o">(</span>
            <span class="o">(</span><span class="nx">m_bIE</span> <span class="o">||</span> <span class="nx">m_bGecko</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
            <span class="o">(</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span> <span class="o">||</span> 
                <span class="o">(</span><span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span><span class="o">)</span>
            <span class="o">)</span>
        <span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">aListeners</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getListeners</span><span class="o">(</span><span class="nx">oForm</span><span class="o">,</span> <span class="s2">&quot;keydown&quot;</span><span class="o">),</span>
                <span class="nx">bHasKeyDownListener</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
    
            <span class="k">if</span><span class="o">(</span><span class="nx">aListeners</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="k">var</span> <span class="nx">nListeners</span> <span class="o">=</span> <span class="nx">aListeners</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
    
                <span class="k">if</span><span class="o">(</span><span class="nx">nListeners</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="nx">nListeners</span> <span class="o">-</span> <span class="m">1</span><span class="o">;</span>
                    
                    <span class="k">do</span> <span class="o">{</span>
       
                        <span class="k">if</span><span class="o">(</span>
                            <span class="nx">aListeners</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">fn</span> <span class="o">==</span> 
                            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">onFormKeyDown</span>
                        <span class="o">)</span> <span class="o">{</span>
        
                            <span class="nx">bHasKeyDownListener</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                            <span class="k">break</span><span class="o">;</span>
                        
                        <span class="o">}</span>
        
                    <span class="o">}</span>
                    <span class="k">while</span><span class="o">(</span><span class="nx">i</span><span class="o">--);</span>
                
                <span class="o">}</span>
            
            <span class="o">}</span>
    
    
            <span class="k">if</span><span class="o">(!</span><span class="nx">bHasKeyDownListener</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span>
                        <span class="nx">oForm</span><span class="o">,</span> 
                        <span class="s2">&quot;keydown&quot;</span><span class="o">,</span> 
                        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">onFormKeyDown</span><span class="o">,</span> 
                        <span class="kc">null</span><span class="o">,</span> 
                        <span class="k">this</span>
                    <span class="o">);</span>
    
            <span class="o">}</span>

        <span class="o">}</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="nx">_originalMaxHeight</span><span class="o">:</span> <span class="o">-</span><span class="m">1</span><span class="o">,</span>


<span class="c">/**</span>
<span class="c">* @method _showMenu</span>
<span class="c">* @description Shows the button&#39;s menu.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event) that triggered the display of</span>
<span class="c">* the menu.</span>
<span class="c">*/</span>
<span class="nx">_showMenu</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oMenu</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">MenuManager</span><span class="o">.</span><span class="nx">hideVisible</span><span class="o">();</span>

        <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">applyConfig</span><span class="o">({</span>
                <span class="nx">context</span><span class="o">:[</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;id&quot;</span><span class="o">),</span> <span class="s2">&quot;tl&quot;</span><span class="o">,</span> <span class="s2">&quot;bl&quot;</span><span class="o">],</span> 
                <span class="nx">clicktohide</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
                <span class="nx">constraintoviewport</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
                <span class="nx">visible</span><span class="o">:</span> <span class="kc">true</span>
            <span class="o">});</span>
            
        <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">fireQueue</span><span class="o">();</span>

        <span class="c">/*</span>
<span class="c">            Stop the propagation of the event so that the MenuManager </span>
<span class="c">            doesn&#39;t blur the menu after it gets focus.</span>
<span class="c">        */</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;mousedown&quot;</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">Event</span><span class="o">.</span><span class="nx">stopPropagation</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">);</span>

        <span class="o">}</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span> 


        <span class="k">var</span> <span class="nx">nViewportHeight</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">getViewportHeight</span><span class="o">(),</span>
            <span class="nx">nMenuHeight</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">offsetHeight</span><span class="o">;</span>


        <span class="k">if</span><span class="o">((</span><span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;y&quot;</span><span class="o">)</span> <span class="o">+</span> <span class="nx">nMenuHeight</span><span class="o">)</span> <span class="o">&gt;</span> <span class="nx">nViewportHeight</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Current menu position will place a portion, or &quot;</span> <span class="o">+</span>
                <span class="s2">&quot;the entire menu outside the boundary of the viewport.  &quot;</span> <span class="o">+</span> 
                <span class="s2">&quot;Repositioning the menu to stay inside the viewport.&quot;</span><span class="o">);</span>

            <span class="nx">oMenu</span><span class="o">.</span><span class="nx">align</span><span class="o">(</span><span class="s2">&quot;bl&quot;</span><span class="o">,</span> <span class="s2">&quot;tl&quot;</span><span class="o">);</span>

            <span class="k">var</span> <span class="nx">nY</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;y&quot;</span><span class="o">),</span>

                <span class="nx">nScrollTop</span> <span class="o">=</span> <span class="o">(</span>
                                <span class="nb">document</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">.</span><span class="nx">scrollTop</span> <span class="o">||</span> 
                                <span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">scrollTop</span>
                            <span class="o">);</span>
            

            <span class="k">if</span><span class="o">(</span><span class="nx">nScrollTop</span> <span class="o">&gt;=</span> <span class="nx">nY</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_originalMaxHeight</span> <span class="o">==</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>

                    <span class="k">this</span><span class="o">.</span><span class="nx">_originalMaxHeight</span> <span class="o">=</span> 
                            <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;maxheight&quot;</span><span class="o">);</span>

                <span class="o">}</span>

                <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span>
                            <span class="s2">&quot;maxheight&quot;</span><span class="o">,</span> 
                            <span class="o">(</span><span class="nx">nMenuHeight</span> <span class="o">-</span> <span class="o">((</span><span class="nx">nScrollTop</span> <span class="o">-</span> <span class="nx">nY</span><span class="o">)</span> <span class="o">+</span> <span class="m">20</span><span class="o">))</span>
                        <span class="o">);</span>

                <span class="nx">oMenu</span><span class="o">.</span><span class="nx">align</span><span class="o">(</span><span class="s2">&quot;bl&quot;</span><span class="o">,</span> <span class="s2">&quot;tl&quot;</span><span class="o">);</span>

            <span class="o">}</span>

        <span class="o">}</span>

        <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;constraintoviewport&quot;</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

    <span class="o">}</span>            

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _hideMenu</span>
<span class="c">* @description Hides the button&#39;s menu.</span>
<span class="c">* @protected</span>
<span class="c">*/</span>
<span class="nx">_hideMenu</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oMenu</span> <span class="o">&amp;&amp;</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;visible&quot;</span><span class="o">))</span> <span class="o">{</span>

        <span class="nx">oMenu</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>

    <span class="o">}</span>

<span class="o">},</span>




<span class="c">// Protected event handlers</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* @method _onMouseOver</span>
<span class="c">* @description &quot;mouseover&quot; event handler for the button.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onMouseOver</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_hasMouseEventHandlers</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;mouseout&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onMouseOut</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;mousedown&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onMouseDown</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;mouseup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onMouseUp</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_hasMouseEventHandlers</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>

    <span class="o">}</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="s2">&quot;hover&quot;</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>

    <span class="o">}</span>


    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_bOptionPressed</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="s2">&quot;activeoption&quot;</span><span class="o">);</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMouseOut</span>
<span class="c">* @description &quot;mouseout&quot; event handler for the button.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onMouseOut</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="s2">&quot;hover&quot;</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="s2">&quot;menubutton&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>

    <span class="o">}</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">_bOptionPressed</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;mouseup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentMouseUp</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

    <span class="o">}</span>
    
<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onDocumentMouseUp</span>
<span class="c">* @description &quot;mouseup&quot; event handler for the button.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onDocumentMouseUp</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_bOptionPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

    <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;menubutton&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;splitbutton&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">((</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;menubutton&quot;</span> <span class="o">?</span> <span class="s2">&quot;active&quot;</span> <span class="o">:</span> <span class="s2">&quot;activeoption&quot;</span><span class="o">));</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenu</span><span class="o">();</span>

    <span class="o">}</span>

    <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;mouseup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentMouseUp</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMouseDown</span>
<span class="c">* @description &quot;mousedown&quot; event handler for the button.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onMouseDown</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">((</span><span class="nx">p_oEvent</span><span class="o">.</span><span class="nx">which</span> <span class="o">||</span> <span class="nx">p_oEvent</span><span class="o">.</span><span class="nx">button</span><span class="o">)</span> <span class="o">==</span> <span class="m">1</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">hasFocus</span><span class="o">())</span> <span class="o">{</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
        
        <span class="o">}</span>


        <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>


        <span class="k">if</span><span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;splitbutton&quot;</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">var</span> <span class="nx">oElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">),</span>
                <span class="nx">nX</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getPageX</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">-</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">getX</span><span class="o">(</span><span class="nx">oElement</span><span class="o">);</span>

            <span class="k">if</span><span class="o">((</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">offsetWidth</span> <span class="o">-</span> <span class="k">this</span><span class="o">.</span><span class="nx">OPTION_AREA_WIDTH</span><span class="o">)</span> <span class="o">&lt;</span> <span class="nx">nX</span><span class="o">)</span> <span class="o">{</span>
                
                <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;option&quot;</span><span class="o">,</span> <span class="nx">p_oEvent</span><span class="o">);</span>

            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>

            <span class="o">}</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;menubutton&quot;</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">))</span> <span class="o">{</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenu</span><span class="o">();</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">_showMenu</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">);</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
            
            <span class="o">}</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        
        <span class="o">}</span>



        <span class="k">if</span><span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;splitbutton&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;menubutton&quot;</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">var</span> <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>

            
            <span class="k">function</span> <span class="nx">onMouseUp</span><span class="o">()</span> <span class="o">{</span>
            
                <span class="nx">me</span><span class="o">.</span><span class="nx">_hideMenu</span><span class="o">();</span>
                <span class="nx">me</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="s2">&quot;mouseup&quot;</span><span class="o">,</span> <span class="nx">onMouseUp</span><span class="o">);</span>
            
            <span class="o">}</span>


            <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenuTimerId</span> <span class="o">=</span> <span class="nb">window</span><span class="o">.</span><span class="nx">setTimeout</span><span class="o">(</span><span class="k">function</span><span class="o">()</span> <span class="o">{</span>
            
                <span class="nx">me</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;mouseup&quot;</span><span class="o">,</span> <span class="nx">onMouseUp</span><span class="o">);</span>
            
            <span class="o">},</span> <span class="m">250</span><span class="o">);</span>

        <span class="o">}</span>

    <span class="o">}</span>
    
<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMouseUp</span>
<span class="c">* @description &quot;mouseup&quot; event handler for the button.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onMouseUp</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_hideMenuTimerId</span><span class="o">)</span> <span class="o">{</span>

        <span class="nb">window</span><span class="o">.</span><span class="nx">clearTimeout</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_hideMenuTimerId</span><span class="o">);</span>

    <span class="o">}</span>

    <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">,</span> <span class="o">!(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">)));</span>
    
    <span class="o">}</span>


    <span class="k">this</span><span class="o">.</span><span class="nx">_activationButtonPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
    

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="s2">&quot;menubutton&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>
    
    <span class="o">}</span>
    
<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onFocus</span>
<span class="c">* @description &quot;focus&quot; event handler for the button.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onFocus</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="s2">&quot;focus&quot;</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_activationKeyPressed</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>
   
    <span class="o">}</span>

    <span class="nx">m_oFocusedButton</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>


    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_hasKeyEventHandlers</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">;</span>

        <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oElement</span><span class="o">,</span> <span class="s2">&quot;blur&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onBlur</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
        <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oElement</span><span class="o">,</span> <span class="s2">&quot;keydown&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onKeyDown</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
        <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nx">oElement</span><span class="o">,</span> <span class="s2">&quot;keyup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onKeyUp</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_hasKeyEventHandlers</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>

    <span class="o">}</span>


    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;focus&quot;</span><span class="o">,</span> <span class="nx">p_oEvent</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onBlur</span>
<span class="c">* @description &quot;blur&quot; event handler for the button.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onBlur</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="s2">&quot;focus&quot;</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="s2">&quot;menubutton&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>

    <span class="o">}</span>    

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_activationKeyPressed</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;keyup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentKeyUp</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

    <span class="o">}</span>


    <span class="nx">m_oFocusedButton</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;blur&quot;</span><span class="o">,</span> <span class="nx">p_oEvent</span><span class="o">);</span>
   
<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onDocumentKeyUp</span>
<span class="c">* @description &quot;keyup&quot; event handler for the document.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onDocumentKeyUp</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_isActivationKey</span><span class="o">(</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)))</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_activationKeyPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
        
        <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;keyup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentKeyUp</span><span class="o">);</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onKeyDown</span>
<span class="c">* @description &quot;keydown&quot; event handler for the button.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onKeyDown</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;splitbutton&quot;</span> <span class="o">&amp;&amp;</span> 
        <span class="k">this</span><span class="o">.</span><span class="nx">_isSplitButtonOptionKey</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span>
    <span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;option&quot;</span><span class="o">,</span> <span class="nx">p_oEvent</span><span class="o">);</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_isActivationKey</span><span class="o">(</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)))</span> <span class="o">{</span>

        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;menubutton&quot;</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">_showMenu</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">);</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">_activationKeyPressed</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
            
            <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>
        
        <span class="o">}</span>
    
    <span class="o">}</span>


    <span class="k">var</span> <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span>
        <span class="nx">oMenu</span> <span class="o">&amp;&amp;</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;visible&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
        <span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">==</span> <span class="m">27</span>
    <span class="o">)</span> <span class="o">{</span>
    
        <span class="nx">oMenu</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onKeyUp</span>
<span class="c">* @description &quot;keyup&quot; event handler for the button.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onKeyUp</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_isActivationKey</span><span class="o">(</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)))</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">,</span> <span class="o">!(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">)));</span>
        
        <span class="o">}</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_activationKeyPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="s2">&quot;menubutton&quot;</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>

        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onClick</span>
<span class="c">* @description &quot;click&quot; event handler for the button.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onClick</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">),</span>
        <span class="nx">sTitle</span><span class="o">;</span>

    <span class="nx">switch</span><span class="o">(</span><span class="nx">sType</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">case</span> <span class="s2">&quot;radio&quot;</span><span class="o">:</span>
        <span class="nx">case</span> <span class="s2">&quot;checkbox&quot;</span><span class="o">:</span>

            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">))</span> <span class="o">{</span>
                
                <span class="nx">sTitle</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">?</span> 
                            <span class="k">this</span><span class="o">.</span><span class="nx">RADIO_CHECKED_TITLE</span> <span class="o">:</span> 
                            <span class="k">this</span><span class="o">.</span><span class="nx">CHECKBOX_CHECKED_TITLE</span><span class="o">;</span>
            
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
            
                <span class="nx">sTitle</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">?</span> 
                            <span class="k">this</span><span class="o">.</span><span class="nx">RADIO_DEFAULT_TITLE</span> <span class="o">:</span> 
                            <span class="k">this</span><span class="o">.</span><span class="nx">CHECKBOX_DEFAULT_TITLE</span><span class="o">;</span>
            
            <span class="o">}</span>
            
            <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">,</span> <span class="nx">sTitle</span><span class="o">);</span>

        <span class="k">break</span><span class="o">;</span>

        <span class="nx">case</span> <span class="s2">&quot;submit&quot;</span><span class="o">:</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">submitForm</span><span class="o">();</span>
        
        <span class="k">break</span><span class="o">;</span>

        <span class="nx">case</span> <span class="s2">&quot;reset&quot;</span><span class="o">:</span>

            <span class="k">var</span> <span class="nx">oForm</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getForm</span><span class="o">();</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">oForm</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">oForm</span><span class="o">.</span><span class="nx">reset</span><span class="o">();</span>
            
            <span class="o">}</span>

        <span class="k">break</span><span class="o">;</span>

        <span class="nx">case</span> <span class="s2">&quot;menubutton&quot;</span><span class="o">:</span>

            <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;visible&quot;</span><span class="o">)</span> <span class="o">?</span> 
                            <span class="k">this</span><span class="o">.</span><span class="nx">MENUBUTTON_MENU_VISIBLE_TITLE</span> <span class="o">:</span> 
                            <span class="k">this</span><span class="o">.</span><span class="nx">MENUBUTTON_DEFAULT_TITLE</span><span class="o">;</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">,</span> <span class="nx">sTitle</span><span class="o">);</span>

        <span class="k">break</span><span class="o">;</span>

        <span class="nx">case</span> <span class="s2">&quot;splitbutton&quot;</span><span class="o">:</span>

            <span class="k">var</span> <span class="nx">oElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">),</span>
                <span class="nx">nX</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getPageX</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">-</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">getX</span><span class="o">(</span><span class="nx">oElement</span><span class="o">);</span>

            <span class="k">if</span><span class="o">((</span><span class="nx">oElement</span><span class="o">.</span><span class="nx">offsetWidth</span> <span class="o">-</span> <span class="k">this</span><span class="o">.</span><span class="nx">OPTION_AREA_WIDTH</span><span class="o">)</span> <span class="o">&lt;</span> <span class="nx">nX</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
            
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>

                <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenu</span><span class="o">();</span>
    
                <span class="k">var</span> <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;srcelement&quot;</span><span class="o">);</span>
    
                <span class="k">if</span><span class="o">(</span><span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="k">this</span><span class="o">.</span><span class="nx">submitForm</span><span class="o">();</span>
                
                <span class="o">}</span>
            
            <span class="o">}</span>

            <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;visible&quot;</span><span class="o">)</span> <span class="o">?</span> 
                            <span class="k">this</span><span class="o">.</span><span class="nx">SPLITBUTTON_OPTION_VISIBLE_TITLE</span> <span class="o">:</span> 
                            <span class="k">this</span><span class="o">.</span><span class="nx">SPLITBUTTON_DEFAULT_TITLE</span><span class="o">;</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">,</span> <span class="nx">sTitle</span><span class="o">);</span>

        <span class="k">break</span><span class="o">;</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onAppendTo</span>
<span class="c">* @description &quot;appendTo&quot; event handler for the button.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onAppendTo</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="c">/*</span>
<span class="c">        It is necessary to call &quot;getForm&quot; using &quot;setTimeout&quot; to make sure that </span>
<span class="c">        the button&#39;s &quot;form&quot; property returns a node reference.  Sometimes, if</span>
<span class="c">        you try to get the reference immediately after appending the field, it</span>
<span class="c">        is null.</span>
<span class="c">    */</span>

    <span class="k">var</span> <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>

    <span class="nb">window</span><span class="o">.</span><span class="nx">setTimeout</span><span class="o">(</span><span class="k">function</span><span class="o">()</span> <span class="o">{</span>

        <span class="nx">me</span><span class="o">.</span><span class="nx">_addListenersToForm</span><span class="o">();</span>

    <span class="o">},</span> <span class="m">0</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onFormSubmit</span>
<span class="c">* @description &quot;submit&quot; event handler for the button&#39;s form.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onFormSubmit</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">),</span>
        <span class="nx">oMenuItem</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;selectedMenuItem&quot;</span><span class="o">),</span>
        <span class="nx">oForm</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getForm</span><span class="o">();</span>
    
    
    <span class="k">if</span><span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Creating hidden field for button: &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">);</span>
    
        <span class="k">this</span><span class="o">.</span><span class="nx">createHiddenField</span><span class="o">();</span>
    
    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">oMenuItem</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="k">var</span> <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">;</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;SELECT&quot;</span><span class="o">)</span> <span class="o">{</span>

            <span class="nx">oForm</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">oSrcElement</span><span class="o">);</span>
            <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">selectedIndex</span> <span class="o">=</span> <span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">index</span><span class="o">;</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
    
            <span class="k">var</span> <span class="nx">oValue</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">value</span> <span class="o">===</span> <span class="kc">null</span> <span class="o">||</span> <span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">value</span> <span class="o">===</span> <span class="s2">&quot;&quot;</span><span class="o">)</span> <span class="o">?</span> 
                                <span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;text&quot;</span><span class="o">)</span> <span class="o">:</span> 
                                <span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>


            <span class="k">if</span><span class="o">(</span><span class="nx">oValue</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="k">var</span> <span class="nx">oField</span> <span class="o">=</span> <span class="nx">createInputElement</span><span class="o">(</span>
                                    <span class="s2">&quot;hidden&quot;</span><span class="o">,</span> 
                                    <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;name&quot;</span><span class="o">)</span> <span class="o">+</span> <span class="s2">&quot;_options&quot;</span><span class="o">),</span>
                                    <span class="nx">oValue</span>
                                <span class="o">);</span>
    
                <span class="nx">oForm</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">oField</span><span class="o">);</span>
    
            <span class="o">}</span>
    
        <span class="o">}</span>                
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onFormReset</span>
<span class="c">* @description &quot;reset&quot; event handler for the button&#39;s form.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onFormReset</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">resetValue</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">);</span>

    <span class="o">}</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">resetValue</span><span class="o">(</span><span class="s2">&quot;selectedMenuItem&quot;</span><span class="o">);</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onDocumentMouseDown</span>
<span class="c">* @description &quot;mousedown&quot; event handler for the document.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onDocumentMouseDown</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oTarget</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">),</span>
        <span class="nx">oButtonElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">),</span>
        <span class="nx">oMenuElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">element</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span>
        <span class="nx">oTarget</span> <span class="o">!=</span> <span class="nx">oButtonElement</span> <span class="o">&amp;&amp;</span> 
        <span class="o">!</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">oButtonElement</span><span class="o">,</span> <span class="nx">oTarget</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
        <span class="nx">oTarget</span> <span class="o">!=</span> <span class="nx">oMenuElement</span> <span class="o">&amp;&amp;</span> 
        <span class="o">!</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">oMenuElement</span><span class="o">,</span> <span class="nx">oTarget</span><span class="o">)</span>
    <span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenu</span><span class="o">();</span>

        <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span>
                <span class="nb">document</span><span class="o">,</span> 
                <span class="s2">&quot;mousedown&quot;</span><span class="o">,</span> 
                <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentMouseDown</span>
            <span class="o">);</span>    
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onOption</span>
<span class="c">* @description &quot;option&quot; event handler for the button.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">_onOption</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="s2">&quot;activeoption&quot;</span><span class="o">))</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenu</span><span class="o">();</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_bOptionPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_showMenu</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">);</span>    

        <span class="k">this</span><span class="o">.</span><span class="nx">_bOptionPressed</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMenuShow</span>
<span class="c">* @description &quot;show&quot; event handler for the button&#39;s menu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">*/</span>
<span class="nx">_onMenuShow</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>

    <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;mousedown&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentMouseDown</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

    <span class="k">var</span> <span class="nx">sTitle</span><span class="o">,</span>
        <span class="nx">sClass</span><span class="o">;</span>
    
    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;splitbutton&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">SPLITBUTTON_OPTION_VISIBLE_TITLE</span><span class="o">;</span>
        <span class="nx">sClass</span> <span class="o">=</span> <span class="s2">&quot;activeoption&quot;</span><span class="o">;</span>
    
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>

        <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">MENUBUTTON_MENU_VISIBLE_TITLE</span><span class="o">;</span>        
        <span class="nx">sClass</span> <span class="o">=</span> <span class="s2">&quot;active&quot;</span><span class="o">;</span>

    <span class="o">}</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">sClass</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">,</span> <span class="nx">sTitle</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMenuHide</span>
<span class="c">* @description &quot;hide&quot; event handler for the button&#39;s menu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">*/</span>
<span class="nx">_onMenuHide</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>
    
    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_originalMaxHeight</span> <span class="o">!=</span> <span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">{</span>
    
        <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;maxheight&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_originalMaxHeight</span><span class="o">);</span>

    <span class="o">}</span>


    <span class="k">var</span> <span class="nx">sTitle</span><span class="o">,</span>
        <span class="nx">sClass</span><span class="o">;</span>
    
    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;splitbutton&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">SPLITBUTTON_DEFAULT_TITLE</span><span class="o">;</span>
        <span class="nx">sClass</span> <span class="o">=</span> <span class="s2">&quot;activeoption&quot;</span><span class="o">;</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>

        <span class="nx">sTitle</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">MENUBUTTON_DEFAULT_TITLE</span><span class="o">;</span>        
        <span class="nx">sClass</span> <span class="o">=</span> <span class="s2">&quot;active&quot;</span><span class="o">;</span>
    <span class="o">}</span>


    <span class="k">this</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">sClass</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">,</span> <span class="nx">sTitle</span><span class="o">);</span>


    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;splitbutton&quot;</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_bOptionPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMenuKeyDown</span>
<span class="c">* @description &quot;keydown&quot; event handler for the button&#39;s menu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">*/</span>
<span class="nx">_onMenuKeyDown</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oEvent</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">)</span> <span class="o">==</span> <span class="m">27</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>

        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;splitbutton&quot;</span><span class="o">)</span> <span class="o">{</span>
        
            <span class="k">this</span><span class="o">.</span><span class="nx">_bOptionPressed</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
        
        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMenuRender</span>
<span class="c">* @description &quot;render&quot; event handler for the button&#39;s menu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">*/</span>
<span class="nx">_onMenuRender</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">).</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">.</span><span class="nx">element</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMenuItemSelected</span>
<span class="c">* @description &quot;selectedchange&quot; event handler for each item in the </span>
<span class="c">* button&#39;s menu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {&lt;a href=&quot;YAHOO.widget.MenuItem.html&quot;&gt;YAHOO.widget.MenuItem&lt;/a&gt;} </span>
<span class="c">* p_oItem Object representing the menu item that subscribed to the event.</span>
<span class="c">*/</span>
<span class="nx">_onMenuItemSelected</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oItem</span><span class="o">)</span> <span class="o">{</span>
    
    <span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="s2">&quot;selectedMenuItem&quot;</span><span class="o">,</span> <span class="nx">p_oItem</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMenuItemAdded</span>
<span class="c">* @description &quot;itemadded&quot; event handler for the button&#39;s menu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">* @param {&lt;a href=&quot;YAHOO.widget.MenuItem.html&quot;&gt;YAHOO.widget.MenuItem&lt;/a&gt;} </span>
<span class="c">* p_oItem Object representing the menu item that subscribed to the event.</span>
<span class="c">*/</span>
<span class="nx">_onMenuItemAdded</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">,</span> <span class="nx">p_oItem</span><span class="o">)</span> <span class="o">{</span>
    
    <span class="k">var</span> <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>

    <span class="nx">oItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">subscribeToConfigEvent</span><span class="o">(</span>
                <span class="s2">&quot;selected&quot;</span><span class="o">,</span> 
                <span class="k">this</span><span class="o">.</span><span class="nx">_onMenuItemSelected</span><span class="o">,</span> 
                <span class="nx">oItem</span><span class="o">,</span> 
                <span class="k">this</span>
            <span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method _onMenuClick</span>
<span class="c">* @description &quot;click&quot; event handler for the button&#39;s menu.</span>
<span class="c">* @private</span>
<span class="c">* @param {String} p_sType String representing the name of the event that </span>
<span class="c">* was fired.</span>
<span class="c">* @param {Array} p_aArgs Array of arguments sent when the event was fired.</span>
<span class="c">*/</span>
<span class="nx">_onMenuClick</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oItem</span> <span class="o">=</span> <span class="nx">p_aArgs</span><span class="o">[</span><span class="m">1</span><span class="o">];</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oItem</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;srcelement&quot;</span><span class="o">);</span>
    
        <span class="k">if</span><span class="o">(</span><span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span><span class="o">)</span> <span class="o">{</span>
    
            <span class="k">this</span><span class="o">.</span><span class="nx">submitForm</span><span class="o">();</span>
    
        <span class="o">}</span>
    
        <span class="k">this</span><span class="o">.</span><span class="nx">_hideMenu</span><span class="o">();</span>
    
    <span class="o">}</span>

<span class="o">},</span>



<span class="c">// Public methods</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* @method createHiddenField</span>
<span class="c">* @description Creates the button&#39;s hidden form field and appends it to its</span>
<span class="c">* parent form.</span>
<span class="c">* @return {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">* one-html.html#ID-6043025&quot;&gt;HTMLInputElement&lt;/a&gt;}</span>
<span class="c">*/</span>
<span class="nx">createHiddenField</span><span class="o">:</span> <span class="k">function</span> <span class="o">()</span> <span class="o">{</span>

    <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">))</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">),</span>
        
            <span class="nx">bCheckable</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">),</span>
        
            <span class="nx">oField</span> <span class="o">=</span> <span class="nx">createInputElement</span><span class="o">(</span>
            
                        <span class="c">/*</span>
<span class="c">                            Use &quot;submit&quot; type for IE so that the input </span>
<span class="c">                            element will be able to be clicked via a call to </span>
<span class="c">                            the &quot;click&quot; method by the &quot;submitForm&quot; method.</span>
<span class="c">                        */</span>
            
                        <span class="o">(</span><span class="nx">bCheckable</span> <span class="o">?</span> <span class="nx">sType</span> <span class="o">:</span> <span class="o">(</span><span class="nx">m_bIE</span> <span class="o">?</span> <span class="s2">&quot;submit&quot;</span> <span class="o">:</span> <span class="s2">&quot;hidden&quot;</span><span class="o">)),</span>
                        <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;name&quot;</span><span class="o">),</span>
                        <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;value&quot;</span><span class="o">),</span>
                        <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">)</span>
                    <span class="o">),</span>
                    
            <span class="nx">oForm</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getForm</span><span class="o">();</span>
    

        <span class="k">if</span> <span class="o">(</span><span class="nx">oField</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">if</span> <span class="o">(</span><span class="nx">bCheckable</span> <span class="o">||</span> <span class="nx">oField</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">oField</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;none&quot;</span><span class="o">;</span>

            <span class="o">}</span>


            <span class="k">if</span> <span class="o">(</span><span class="nx">oForm</span><span class="o">)</span> <span class="o">{</span>
        
                <span class="k">var</span> <span class="nx">oHiddenField</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_hiddenField</span><span class="o">;</span>
        
                <span class="k">if</span> <span class="o">(</span><span class="nx">oHiddenField</span> <span class="o">&amp;&amp;</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">inDocument</span><span class="o">(</span><span class="nx">oHiddenField</span><span class="o">))</span> <span class="o">{</span>
        
                    <span class="nx">oForm</span><span class="o">.</span><span class="nx">replaceChild</span><span class="o">(</span><span class="nx">oField</span><span class="o">,</span> <span class="nx">oHiddenField</span><span class="o">);</span>
        
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
        
                    <span class="nx">oForm</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">oField</span><span class="o">);</span>
                    
                <span class="o">}</span>
            
            <span class="o">}</span>
    
            <span class="k">this</span><span class="o">.</span><span class="nx">_hiddenField</span> <span class="o">=</span> <span class="nx">oField</span><span class="o">;</span>
    
            <span class="k">return</span> <span class="nx">oField</span><span class="o">;</span>

        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method submitForm</span>
<span class="c">* @description Submits the form to which the button belongs.</span>
<span class="c">* @protected</span>
<span class="c">*/</span>
<span class="nx">submitForm</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oMenuItem</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oForm</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getForm</span><span class="o">();</span>

    <span class="k">if</span> <span class="o">(</span><span class="nx">oForm</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oInput</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">createHiddenField</span><span class="o">();</span>

        <span class="k">if</span> <span class="o">(</span><span class="nx">m_bIE</span><span class="o">)</span> <span class="o">{</span>

            <span class="c">/*</span>
<span class="c">                Clicking the button via a call to the &quot;click&quot; method will </span>
<span class="c">                cause IE to both fire the form&#39;s &quot;submit&quot; event as well as </span>
<span class="c">                submit the form.  Originally tried just firing the &quot;submit&quot;</span>
<span class="c">                event via &quot;fireEvent,&quot; but then the event could not </span>
<span class="c">                be cancelled.</span>
<span class="c">            */</span>            

            <span class="nx">oInput</span><span class="o">.</span><span class="nx">click</span><span class="o">();</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>  <span class="c">// Gecko, Opera, and Safari</span>
<span class="c"></span>
            <span class="k">var</span> <span class="nx">oEvent</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;HTMLEvents&quot;</span><span class="o">);</span>
            <span class="nx">oEvent</span><span class="o">.</span><span class="nx">initEvent</span><span class="o">(</span><span class="s2">&quot;submit&quot;</span><span class="o">,</span> <span class="kc">true</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

            <span class="c">/*</span>
<span class="c">                In Safari, dispatching a &quot;submit&quot; event to a form WILL cause  </span>
<span class="c">                the form&#39;s &quot;submit&quot; event to fire, but WILL NOT submit the   </span>
<span class="c">                form.  Therefore, we need to call the &quot;submit&quot; method as well.</span>
<span class="c">            */</span>

            <span class="k">var</span> <span class="nx">bSubmitForm</span> <span class="o">=</span> <span class="nx">oForm</span><span class="o">.</span><span class="nx">dispatchEvent</span><span class="o">(</span><span class="nx">oEvent</span><span class="o">);</span>
          
            <span class="k">if</span><span class="o">(</span><span class="nx">m_bSafari</span> <span class="o">&amp;&amp;</span> <span class="nx">bSubmitForm</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">oForm</span><span class="o">.</span><span class="nx">submit</span><span class="o">();</span>
            
            <span class="o">}</span>

        <span class="o">}</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method init</span>
<span class="c">* @description The Button class&#39;s initialization method.</span>
<span class="c">* @param {String} p_oElement String specifying the id attribute of the </span>
<span class="c">* &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt;, &lt;code&gt;&amp;#60;a&amp;#62;&lt;/code&gt; or </span>
<span class="c">* &lt;code&gt;&amp;#60;span&amp;#62;&lt;/code&gt; element to be used to create the button.</span>
<span class="c">* @param {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">* one-html.html#ID-6043025&quot;&gt;HTMLInputElement&lt;/a&gt;|&lt;a href=&quot;</span>
<span class="c">* http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#</span>
<span class="c">* ID-33759296&quot;&gt;HTMLElement&lt;/a&gt;} p_oElement Object reference for the </span>
<span class="c">* &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt;, &lt;code&gt;&amp;#60;a&amp;#62;&lt;/code&gt; or </span>
<span class="c">* &lt;code&gt;&amp;#60;span&amp;#62;&lt;/code&gt; element to be used to create the button.</span>
<span class="c">* @param {Object} p_oElement Object literal specifying a set of configuration </span>
<span class="c">* attributes used to create the button.</span>
<span class="c">* @param {Object} p_oAttributes Optional. Object literal specifying a set of  </span>
<span class="c">* configuration attributes used to create the button.</span>
<span class="c">*/</span>
<span class="nx">init</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">,</span> <span class="nx">p_oAttributes</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">sTagName</span> <span class="o">=</span> <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;link&quot;</span> <span class="o">?</span> <span class="s2">&quot;A&quot;</span> <span class="o">:</span> <span class="s2">&quot;BUTTON&quot;</span><span class="o">,</span>
        <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="nx">p_oAttributes</span><span class="o">.</span><span class="nx">srcelement</span><span class="o">;</span>


    <span class="k">this</span><span class="o">.</span><span class="nx">_button</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">getElementsByTagName</span><span class="o">(</span><span class="nx">sTagName</span><span class="o">)[</span><span class="m">0</span><span class="o">];</span>


    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">init</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span>
            <span class="k">this</span><span class="o">,</span> <span class="nx">p_oElement</span><span class="o">,</span> 
            <span class="nx">p_oAttributes</span>
        <span class="o">);</span>


    <span class="nx">m_oButtons</span><span class="o">[</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;id&quot;</span><span class="o">)]</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>


    <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">CSS_CLASS_NAME</span><span class="o">);</span>
    
    <span class="k">if</span><span class="o">(</span><span class="nx">m_bIE</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">m_bIE7</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="s2">&quot;ie6&quot;</span><span class="o">);</span>

    <span class="o">}</span>
    
    <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">));</span>

    <span class="nx">Event</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">,</span> <span class="s2">&quot;focus&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onFocus</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;mouseover&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onMouseOver</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onClick</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">on</span><span class="o">(</span><span class="s2">&quot;appendTo&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onAppendTo</span><span class="o">);</span>
    
    <span class="k">var</span> <span class="nx">oContainer</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;container&quot;</span><span class="o">),</span>
        <span class="nx">oElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">);</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">oContainer</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">oContainer</span><span class="o">))</span> <span class="o">{</span>

            <span class="k">var</span> <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>

            <span class="nx">Event</span><span class="o">.</span><span class="nx">onContentReady</span><span class="o">(</span><span class="nx">oContainer</span><span class="o">,</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

                <span class="nx">me</span><span class="o">.</span><span class="nx">appendTo</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>            
            
            <span class="o">});</span>

        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">appendTo</span><span class="o">(</span><span class="nx">oContainer</span><span class="o">);</span>

        <span class="o">}</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span>
        <span class="o">!</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">inDocument</span><span class="o">(</span><span class="nx">oElement</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
        <span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> 
        <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;INPUT&quot;</span>
    <span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">oParentNode</span> <span class="o">=</span> <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">oParentNode</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;beforeAppendTo&quot;</span><span class="o">,</span> <span class="o">{</span>
                <span class="nx">type</span><span class="o">:</span> <span class="s2">&quot;beforeAppendTo&quot;</span><span class="o">,</span>
                <span class="nx">target</span><span class="o">:</span> <span class="nx">oParentNode</span>
            <span class="o">});</span>
    
            <span class="nx">oParentNode</span><span class="o">.</span><span class="nx">replaceChild</span><span class="o">(</span><span class="nx">oElement</span><span class="o">,</span> <span class="nx">oSrcElement</span><span class="o">);</span>
    
            <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;appendTo&quot;</span><span class="o">,</span> <span class="o">{</span>
                <span class="nx">type</span><span class="o">:</span> <span class="s2">&quot;appendTo&quot;</span><span class="o">,</span>
                <span class="nx">target</span><span class="o">:</span> <span class="nx">oParentNode</span>
            <span class="o">});</span>
        
        <span class="o">}</span>

    <span class="o">}</span>
    <span class="k">else</span> <span class="k">if</span><span class="o">(</span>
        <span class="nx">Dom</span><span class="o">.</span><span class="nx">inDocument</span><span class="o">(</span><span class="nx">oElement</span><span class="o">)</span> <span class="o">&amp;&amp;</span> 
        <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;SPAN&quot;</span>
    <span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_addListenersToForm</span><span class="o">();</span>

    <span class="o">}</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Initialization completed.&quot;</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method initAttributes</span>
<span class="c">* @description Initializes all of the configuration attributes used to create </span>
<span class="c">* the button.</span>
<span class="c">* @param {Object} p_oAttributes Object literal specifying a set of </span>
<span class="c">* configuration attributes used to create the button.</span>
<span class="c">*/</span>
<span class="nx">initAttributes</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oAttributes</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oAttributes</span> <span class="o">=</span> <span class="nx">p_oAttributes</span> <span class="o">||</span> <span class="o">{};</span>

    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">initAttributes</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">oAttributes</span><span class="o">);</span>


    <span class="c">/**</span>
<span class="c">    * @config type</span>
<span class="c">    * @description String specifying the button&#39;s type.  Possible values are: </span>
<span class="c">    * &quot;button,&quot; &quot;link,&quot; &quot;submit,&quot; &quot;reset,&quot; &quot;checkbox,&quot; &quot;radio,&quot; &quot;menubutton,&quot; </span>
<span class="c">    * and &quot;splitbutton.&quot;</span>
<span class="c">    * @default &quot;button&quot;</span>
<span class="c">    * @type String</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="o">(</span><span class="nx">oAttributes</span><span class="o">.</span><span class="nx">type</span> <span class="o">||</span> <span class="s2">&quot;button&quot;</span><span class="o">),</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">,</span>
        <span class="nx">writeOnce</span><span class="o">:</span> <span class="kc">true</span><span class="o">,</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setType</span>

    <span class="o">});</span>


    <span class="c">/**</span>
<span class="c">    * @config label</span>
<span class="c">    * @description String specifying the button&#39;s text label or innerHTML.</span>
<span class="c">    * @default null</span>
<span class="c">    * @type String</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;label&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="k">label</span><span class="o">,</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">,</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setLabel</span>

    <span class="o">});</span>


    <span class="c">/**</span>
<span class="c">    * @config value</span>
<span class="c">    * @description Object specifying the value for the button.</span>
<span class="c">    * @default null</span>
<span class="c">    * @type Object</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;value&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">value</span>

    <span class="o">});</span>


    <span class="c">/**</span>
<span class="c">    * @config name</span>
<span class="c">    * @description String specifying the name for the button.</span>
<span class="c">    * @default null</span>
<span class="c">    * @type String</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;name&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">name</span><span class="o">,</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span>

    <span class="o">});</span>


    <span class="c">/**</span>
<span class="c">    * @config tabindex</span>
<span class="c">    * @description Number specifying the tabindex for the button.</span>
<span class="c">    * @default null</span>
<span class="c">    * @type Number</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;tabindex&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">tabindex</span><span class="o">,</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">,</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setTabIndex</span>

    <span class="o">});</span>


    <span class="c">/**</span>
<span class="c">    * @config title</span>
<span class="c">    * @description String specifying the title for the button.</span>
<span class="c">    * @default null</span>
<span class="c">    * @type String</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">configureAttribute</span><span class="o">(</span><span class="s2">&quot;title&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">title</span><span class="o">,</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">,</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setTitle</span>

    <span class="o">});</span>


    <span class="c">/**</span>
<span class="c">    * @config disabled</span>
<span class="c">    * @description Boolean indicating if the button should be disabled.  </span>
<span class="c">    * (Disabled buttons are dimmed and will not respond to user input </span>
<span class="c">    * or fire events.  Does not apply to button&#39;s of type &quot;link.&quot;)</span>
<span class="c">    * @default false</span>
<span class="c">    * @type Boolean</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="o">(</span><span class="nx">oAttributes</span><span class="o">.</span><span class="nx">disabled</span> <span class="o">||</span> <span class="kc">false</span><span class="o">),</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isBoolean</span><span class="o">,</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setDisabled</span>

    <span class="o">});</span>


    <span class="c">/**</span>
<span class="c">    * @config href</span>
<span class="c">    * @description String specifying the href for the button.  Applies only to </span>
<span class="c">    * buttons of type &quot;link.&quot;</span>
<span class="c">    * @type String</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;href&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">href</span><span class="o">,</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">,</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setHref</span>

    <span class="o">});</span>


    <span class="c">/**</span>
<span class="c">    * @config target</span>
<span class="c">    * @description String specifying the target for the button.  Applies only  </span>
<span class="c">    * to buttons of type &quot;link.&quot;</span>
<span class="c">    * @type String</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;target&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">target</span><span class="o">,</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isString</span><span class="o">,</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setTarget</span>

    <span class="o">});</span>


    <span class="c">/**</span>
<span class="c">    * @config checked</span>
<span class="c">    * @description Boolean indicating if the button is checked.  Applies only</span>
<span class="c">    * to buttons of type &quot;radio&quot; and &quot;checkbox.&quot;</span>
<span class="c">    * @default false</span>
<span class="c">    * @type Boolean</span>
<span class="c">    */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;checked&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="o">(</span><span class="nx">oAttributes</span><span class="o">.</span><span class="nx">checked</span> <span class="o">||</span> <span class="kc">false</span><span class="o">),</span>
        <span class="nx">validator</span><span class="o">:</span> <span class="nx">Lang</span><span class="o">.</span><span class="nx">isBoolean</span><span class="o">,</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setChecked</span>

    <span class="o">});</span>


	<span class="c">/**</span>
<span class="c">	* @config container</span>
<span class="c">	* @description HTML element reference or string specifying the id </span>
<span class="c">	* attribute of the HTML element that the button&#39;s markup should be </span>
<span class="c">	* rendered into.</span>
<span class="c">	* @type &lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">	* level-one-html.html#ID-58190037&quot;&gt;HTMLElement&lt;/a&gt;|String</span>
<span class="c">	* @default null</span>
<span class="c">	*/</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;container&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">container</span>

    <span class="o">});</span>


	<span class="c">/**</span>
<span class="c">	* @config srcelement</span>
<span class="c">    * @description Object reference to the HTML element (either </span>
<span class="c">    * &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; or &lt;code&gt;&amp;#60;span&amp;#62;&lt;/code&gt;) used to </span>
<span class="c">    * create the button.</span>
<span class="c">	* @type &lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">	* level-one-html.html#ID-58190037&quot;&gt;HTMLElement&lt;/a&gt;|String</span>
<span class="c">	* @default null</span>
<span class="c">	*/</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;srcelement&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">srcelement</span><span class="o">,</span>
        <span class="nx">writeOnce</span><span class="o">:</span> <span class="kc">true</span>

    <span class="o">});</span>


	<span class="c">/**</span>
<span class="c">	* @config menu</span>
<span class="c">    * @description Object specifying the menu for the button.  The value can be</span>
<span class="c">    * one of the following:</span>
<span class="c">    * &lt;ul&gt;</span>
<span class="c">    * &lt;li&gt;Object specifying a &lt;a href=&quot;YAHOO.widget.Menu.html&quot;&gt;</span>
<span class="c">    * YAHOO.widget.Menu&lt;/a&gt; instance.&lt;/li&gt;</span>
<span class="c">    * &lt;li&gt;String specifying the id attribute of the &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; </span>
<span class="c">    * element used to create the menu.&lt;/li&gt;</span>
<span class="c">    * &lt;li&gt;String specifying the id attribute of the </span>
<span class="c">    * &lt;code&gt;&amp;#60;select&amp;#62;&lt;/code&gt; element used to create the menu.&lt;/li&gt;</span>
<span class="c">    * &lt;li&gt;Object specifying the &lt;code&gt;&amp;#60;div&amp;#62;&lt;/code&gt; element used to </span>
<span class="c">    * create the menu.&lt;/li&gt;</span>
<span class="c">    * &lt;li&gt;Object specifying the &lt;code&gt;&amp;#60;select&amp;#62;&lt;/code&gt; element used to </span>
<span class="c">    * create the menu.&lt;/li&gt;</span>
<span class="c">    * &lt;li&gt;Array of object literals, each representing a set of </span>
<span class="c">    * &lt;a href=&quot;YAHOO.widget.MenuItem.html&quot;&gt;YAHOO.widget.MenuItem&lt;/a&gt; </span>
<span class="c">    * configuration attributes.&lt;/li&gt;</span>
<span class="c">    * &lt;li&gt;Array of strings representing the text labels for each menu item in </span>
<span class="c">    * the menu.&lt;/li&gt;</span>
<span class="c">    * &lt;/ul&gt;</span>
<span class="c">	* @type &lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/</span>
<span class="c">	* level-one-html.html#ID-58190037&quot;&gt;HTMLElement&lt;/a&gt;|String|Array</span>
<span class="c">	* @default null</span>
<span class="c">	*/</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;menu&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setMenu</span>
    
    <span class="o">});</span>


	<span class="c">/**</span>
<span class="c">	* @config selectedMenuItem</span>
<span class="c">    * @description Reference to the item in the button&#39;s menu that is</span>
<span class="c">    * currently selected.</span>
<span class="c">	* @type &lt;a href=&quot;YAHOO.widget.MenuItem.html&quot;&gt;YAHOO.widget.MenuItem&lt;/a&gt;</span>
<span class="c">	* @default null</span>
<span class="c">	*/</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;selectedMenuItem&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="kc">null</span>
    
    <span class="o">});</span>


	<span class="c">/**</span>
<span class="c">	* @config onclick</span>
<span class="c">    * @description Object literal representing the code to be executed when </span>
<span class="c">    * the button is clicked.  Format:&lt;br&gt; &lt;code&gt; {&lt;br&gt; </span>
<span class="c">    * &lt;strong&gt;fn:&lt;/strong&gt; Function,   &amp;#47;&amp;#47; The handler to call when the </span>
<span class="c">    * event fires.&lt;br&gt; &lt;strong&gt;obj:&lt;/strong&gt; Object, &amp;#47;&amp;#47; An object to </span>
<span class="c">    * pass back to the handler.&lt;br&gt; &lt;strong&gt;scope:&lt;/strong&gt; Object &amp;#47;&amp;#47; </span>
<span class="c">    * The object to use for the scope of the handler.&lt;br&gt; } &lt;/code&gt;</span>
<span class="c">    * @type Object</span>
<span class="c">	* @default null</span>
<span class="c">	*/</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">setAttributeConfig</span><span class="o">(</span><span class="s2">&quot;onclick&quot;</span><span class="o">,</span> <span class="o">{</span>

        <span class="nx">value</span><span class="o">:</span> <span class="nx">oAttributes</span><span class="o">.</span><span class="nx">onclick</span><span class="o">,</span>
        <span class="nx">method</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_setOnClick</span>
    
    <span class="o">});</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method focus</span>
<span class="c">* @description Causes the button to receive the focus and fires the button&#39;s</span>
<span class="c">* &quot;focus&quot; event.</span>
<span class="c">*/</span>
<span class="nx">focus</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">))</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
    
    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method blur</span>
<span class="c">* @description Causes the button to lose focus and fires the button&#39;s</span>
<span class="c">* &quot;blur&quot; event.</span>
<span class="c">*/</span>
<span class="nx">blur</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">))</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">blur</span><span class="o">();</span>

    <span class="o">}</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method hasFocus</span>
<span class="c">* @description Returns a boolean indicating whether or not the button has focus.</span>
<span class="c">* @return {Boolean}</span>
<span class="c">*/</span>
<span class="nx">hasFocus</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">return</span> <span class="o">(</span><span class="nx">m_oFocusedButton</span> <span class="o">==</span> <span class="k">this</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method isActive</span>
<span class="c">* @description Returns a boolean indicating whether or not the button is active.</span>
<span class="c">* @return {Boolean}</span>
<span class="c">*/</span>
<span class="nx">isActive</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="s2">&quot;active&quot;</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method getMenu</span>
<span class="c">* @description Returns a reference to the button&#39;s menu.</span>
<span class="c">* @return {&lt;a href=&quot;YAHOO.widget.Menu.html&quot;&gt;YAHOO.widget.Menu&lt;/a&gt;}</span>
<span class="c">*/</span>
<span class="nx">getMenu</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">;</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method getForm</span>
<span class="c">* @description Returns a reference to the button&#39;s parent form.</span>
<span class="c">* @return {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">* one-html.html#ID-40002357&quot;&gt;HTMLFormElement&lt;/a&gt;}</span>
<span class="c">*/</span>
<span class="nx">getForm</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">.</span><span class="nx">form</span><span class="o">;</span>

<span class="o">},</span>


<span class="c">/** </span>
<span class="c">* @method getHiddenField</span>
<span class="c">* @description Returns a reference to the &lt;code&gt;&amp;#60;input&amp;#62;&lt;/code&gt; element </span>
<span class="c">* used when the button&#39;s parent form is submitted.</span>
<span class="c">* @return {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">* one-html.html#ID-6043025&quot;&gt;HTMLInputElement&lt;/a&gt;}</span>
<span class="c">*/</span>
<span class="nx">getHiddenField</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_hiddenField</span><span class="o">;</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method destroy</span>
<span class="c">* @description Removes the button&#39;s element from its parent element and </span>
<span class="c">* removes all event handlers.</span>
<span class="c">*/</span>
<span class="nx">destroy</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Destroying ...&quot;</span><span class="o">);</span>

    <span class="k">var</span> <span class="nx">oElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;element&quot;</span><span class="o">),</span>
        <span class="nx">oParentNode</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">,</span>
        <span class="nx">oMenu</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_menu</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oMenu</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Destroying menu.&quot;</span><span class="o">);</span>

        <span class="nx">oMenu</span><span class="o">.</span><span class="nx">destroy</span><span class="o">();</span>

    <span class="o">}</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Removing DOM event handlers.&quot;</span><span class="o">);</span>

    <span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="nx">oElement</span><span class="o">);</span>
    <span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_button</span><span class="o">);</span>
    <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;mouseup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentMouseUp</span><span class="o">);</span>
    <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;keyup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentKeyUp</span><span class="o">);</span>
    <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;mousedown&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentMouseDown</span><span class="o">);</span>


    <span class="k">var</span> <span class="nx">oForm</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getForm</span><span class="o">();</span>
    
    <span class="k">if</span><span class="o">(</span><span class="nx">oForm</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nx">oForm</span><span class="o">,</span> <span class="s2">&quot;reset&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onFormReset</span><span class="o">);</span>
        <span class="nx">Event</span><span class="o">.</span><span class="nx">removeListener</span><span class="o">(</span><span class="nx">oForm</span><span class="o">,</span> <span class="s2">&quot;submit&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onFormSubmit</span><span class="o">);</span>

    <span class="o">}</span>


    <span class="nx">oParentNode</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">oElement</span><span class="o">);</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Removing from document.&quot;</span><span class="o">);</span>

    <span class="nx">delete</span> <span class="nx">m_oButtons</span><span class="o">[</span><span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;id&quot;</span><span class="o">)];</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Destroyed.&quot;</span><span class="o">);</span>

<span class="o">},</span>


<span class="nx">fireEvent</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_sType</span> <span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">)</span> <span class="o">{</span>

    <span class="c">//  Disabled buttons should not respond to DOM events</span>
<span class="c"></span>
    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">DOM_EVENTS</span><span class="o">[</span><span class="nx">p_sType</span><span class="o">]</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;disabled&quot;</span><span class="o">))</span> <span class="o">{</span>

        <span class="k">return</span><span class="o">;</span>

    <span class="o">}</span>

    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">p_sType</span><span class="o">,</span> <span class="nx">p_aArgs</span><span class="o">);</span>

<span class="o">},</span>


<span class="c">/**</span>
<span class="c">* @method toString</span>
<span class="c">* @description Returns a string representing the button.</span>
<span class="c">* @return {String}</span>
<span class="c">*/</span>
<span class="nx">toString</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">return</span> <span class="o">(</span><span class="s2">&quot;Button &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;id&quot;</span><span class="o">));</span>

<span class="o">}</span>

<span class="o">});</span>


<span class="c">/**</span>
<span class="c">* @method onFormKeyDown</span>
<span class="c">* @description &quot;keydown&quot; event handler for the button&#39;s form.</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">onFormKeyDown</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oTarget</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">),</span>
        <span class="nx">nCharCode</span> <span class="o">=</span> <span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">);</span>


    <span class="k">if</span> <span class="o">(</span>
        <span class="nx">nCharCode</span> <span class="o">==</span> <span class="m">13</span> <span class="o">&amp;&amp;</span> 
        <span class="nx">oTarget</span><span class="o">.</span><span class="nx">tagName</span> <span class="o">&amp;&amp;</span> 
        <span class="nx">oTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;INPUT&quot;</span>
    <span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="nx">oTarget</span><span class="o">.</span><span class="nx">type</span><span class="o">;</span>


        <span class="k">if</span><span class="o">(</span>
            <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;text&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;password&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> 
            <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;file&quot;</span>
        <span class="o">)</span> <span class="o">{</span>


            <span class="k">function</span> <span class="nx">isYUISubmitButton</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="k">var</span> <span class="nx">sId</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
    
                <span class="k">if</span> <span class="o">(</span><span class="nx">sId</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="k">var</span> <span class="nx">oButton</span> <span class="o">=</span> <span class="nx">m_oButtons</span><span class="o">[</span><span class="nx">sId</span><span class="o">];</span>
        
                    <span class="k">if</span> <span class="o">(</span><span class="nx">oButton</span><span class="o">)</span> <span class="o">{</span>
        
                        <span class="k">var</span> <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="nx">oButton</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;srcelement&quot;</span><span class="o">);</span>
        
                        <span class="k">return</span> <span class="o">(</span>
                                    <span class="nx">oButton</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">)</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span> <span class="o">||</span> 
                                    <span class="o">(</span>
                                        <span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> 
                                        <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">type</span> <span class="o">==</span> <span class="s2">&quot;submit&quot;</span>
                                    <span class="o">)</span>
                                <span class="o">);</span>
        
                    <span class="o">}</span>
                
                <span class="o">}</span>
            
            <span class="o">}</span>
    
    
            <span class="k">var</span> <span class="nx">aButtons</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsBy</span><span class="o">(</span>
                                <span class="nx">isYUISubmitButton</span><span class="o">,</span>
                                <span class="k">this</span><span class="o">.</span><span class="nx">TAG_NAME</span><span class="o">,</span> 
                                <span class="k">this</span><span class="o">.</span><span class="nx">getForm</span><span class="o">()</span>
                            <span class="o">),</span>
    
                <span class="nx">nButtons</span> <span class="o">=</span> <span class="nx">aButtons</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
    
    
            <span class="k">if</span> <span class="o">(</span><span class="nx">nButtons</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
    
                <span class="nx">m_oButtons</span><span class="o">[</span><span class="nx">aButtons</span><span class="o">[</span><span class="m">0</span><span class="o">].</span><span class="nx">id</span><span class="o">].</span><span class="nx">submitForm</span><span class="o">();</span>
            
            <span class="o">}</span>

        
        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">};</span>


<span class="c">/**</span>
<span class="c">* @method addHiddenFieldsToForm</span>
<span class="c">* @description Searches the specified form and adds hidden fields for instances </span>
<span class="c">* of YAHOO.widget.Button that are of type &quot;radio,&quot; &quot;checkbox,&quot; &quot;menubutton,&quot; </span>
<span class="c">* and &quot;splitbutton.&quot;</span>
<span class="c">* @param {&lt;a href=&quot;http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-</span>
<span class="c">* one-html.html#ID-40002357&quot;&gt;HTMLFormElement&lt;/a&gt;} p_oForm Object reference </span>
<span class="c">* for the form to search.</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Button</span><span class="o">.</span><span class="nx">addHiddenFieldsToForm</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oForm</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">aButtons</span> <span class="o">=</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="s2">&quot;yuibutton&quot;</span><span class="o">,</span> <span class="s2">&quot;*&quot;</span><span class="o">,</span> <span class="nx">p_oForm</span><span class="o">),</span>
        <span class="nx">nButtons</span> <span class="o">=</span> <span class="nx">aButtons</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>


    <span class="k">if</span><span class="o">(</span><span class="nx">nButtons</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Form contains &quot;</span> <span class="o">+</span> <span class="nx">nButtons</span> <span class="o">+</span> <span class="s2">&quot; YUI buttons.&quot;</span><span class="o">);</span>

        <span class="k">var</span> <span class="nx">oButton</span> <span class="o">=</span> <span class="kc">null</span><span class="o">,</span>
            <span class="nx">sType</span> <span class="o">=</span> <span class="kc">null</span><span class="o">,</span>
            <span class="nx">oMenuItem</span> <span class="o">=</span> <span class="kc">null</span><span class="o">,</span>
            <span class="nx">oMenu</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">nButtons</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>

            <span class="nx">oButton</span> <span class="o">=</span> <span class="nx">m_oButtons</span><span class="o">[</span><span class="nx">aButtons</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">id</span><span class="o">];</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">oButton</span><span class="o">)</span> <span class="o">{</span>

                <span class="nx">sType</span> <span class="o">=</span> <span class="nx">oButton</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">);</span>
                <span class="nx">oMenuItem</span> <span class="o">=</span> <span class="nx">oButton</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;selectedMenuItem&quot;</span><span class="o">);</span>


                <span class="k">if</span><span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Creating hidden field for button: &quot;</span> <span class="o">+</span> <span class="nx">oButton</span><span class="o">);</span>
    
                    <span class="nx">oButton</span><span class="o">.</span><span class="nx">createHiddenField</span><span class="o">();</span>
                
                <span class="o">}</span>
                <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">oMenuItem</span><span class="o">)</span> <span class="o">{</span>
    
                    <span class="nx">oMenu</span> <span class="o">=</span> <span class="nx">oButton</span><span class="o">.</span><span class="nx">getMenu</span><span class="o">();</span>
    
                    <span class="k">var</span> <span class="nx">oSrcElement</span> <span class="o">=</span> <span class="nx">oMenu</span><span class="o">.</span><span class="nx">srcElement</span><span class="o">;</span>
                        
                    <span class="k">if</span><span class="o">(</span>
                        <span class="nx">oSrcElement</span> <span class="o">&amp;&amp;</span> 
                        <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;SELECT&quot;</span>
                    <span class="o">)</span> <span class="o">{</span>
            
                        <span class="nx">p_oForm</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">oSrcElement</span><span class="o">);</span>
                        <span class="nx">oSrcElement</span><span class="o">.</span><span class="nx">selectedIndex</span> <span class="o">=</span> <span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">index</span><span class="o">;</span>
            
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="o">{</span>
    
                        <span class="k">var</span> <span class="nx">oValue</span> <span class="o">=</span> <span class="o">(</span>
                                        <span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">value</span> <span class="o">===</span> <span class="kc">null</span> <span class="o">||</span> 
                                        <span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">value</span> <span class="o">===</span> <span class="s2">&quot;&quot;</span>
                                    <span class="o">)</span> <span class="o">?</span> <span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;text&quot;</span><span class="o">)</span> <span class="o">:</span> 
                                    <span class="nx">oMenuItem</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>

                        <span class="k">if</span><span class="o">(</span><span class="nx">oValue</span><span class="o">)</span> <span class="o">{</span>

                            <span class="k">var</span> <span class="nx">oHiddenField</span> <span class="o">=</span> <span class="nx">oButton</span><span class="o">.</span><span class="nx">getHiddenField</span><span class="o">(),</span>
    
                                <span class="nx">oField</span> <span class="o">=</span> <span class="nx">createInputElement</span><span class="o">(</span>
                                            <span class="s2">&quot;hidden&quot;</span><span class="o">,</span>
                                            <span class="o">(</span><span class="nx">oButton</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s2">&quot;name&quot;</span><span class="o">)</span> <span class="o">+</span> <span class="s2">&quot;_options&quot;</span><span class="o">),</span>
                                            <span class="nx">oValue</span>
                                        <span class="o">);</span>
                                        
                            <span class="k">if</span><span class="o">(</span><span class="nx">oHiddenField</span> <span class="o">&amp;&amp;</span> <span class="nx">Dom</span><span class="o">.</span><span class="nx">inDocument</span><span class="o">(</span><span class="nx">oHiddenField</span><span class="o">))</span> <span class="o">{</span>

                                <span class="nx">p_oForm</span><span class="o">.</span><span class="nx">replaceChild</span><span class="o">(</span><span class="nx">oField</span><span class="o">,</span> <span class="nx">oHiddenField</span><span class="o">);</span>

                            <span class="o">}</span>
                            <span class="k">else</span> <span class="o">{</span>

                                <span class="nx">p_oForm</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">oField</span><span class="o">);</span>
                            
                            <span class="o">}</span>
    
                        <span class="o">}</span>
    
                    <span class="o">}</span>                
    
                <span class="o">}</span>
                
            <span class="o">}</span>
        
        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">};</span>



<span class="c">// Events</span>
<span class="c"></span>

<span class="c">/**</span>
<span class="c">* @event focus</span>
<span class="c">* @description Fires when the menu item receives focus.  Passes back a single </span>
<span class="c">* object representing the original DOM event object passed back by the event </span>
<span class="c">* utility (YAHOO.util.Event) when the event was fired.  See &lt;a href=&quot;</span>
<span class="c">* YAHOO.util.Element.html#addListener&quot;&gt;Element.addListener&lt;/a&gt; for more </span>
<span class="c">* information on listening for this event.</span>
<span class="c">* @type YAHOO.util.CustomEvent</span>
<span class="c">*/</span>


<span class="c">/**</span>
<span class="c">* @event blur</span>
<span class="c">* @description Fires when the menu item loses the input focus.  Passes back a </span>
<span class="c">* single object representing the original DOM event object passed back by the </span>
<span class="c">* event utility (YAHOO.util.Event) when the event was fired.  See &lt;a href=&quot;</span>
<span class="c">* YAHOO.util.Element.html#addListener&quot;&gt;Element.addListener&lt;/a&gt; for more </span>
<span class="c">* information on listening for this event.</span>
<span class="c">* @type YAHOO.util.CustomEvent</span>
<span class="c">*/</span>


<span class="c">/**</span>
<span class="c">* @event option</span>
<span class="c">* @description Fires when the user invokes the button&#39;s option.  Passes back a </span>
<span class="c">* single object representing the original DOM event (either &quot;mousedown&quot; or </span>
<span class="c">* &quot;keydown&quot;) that caused the &quot;option&quot; event to fire.  See &lt;a href=&quot;</span>
<span class="c">* YAHOO.util.Element.html#addListener&quot;&gt;Element.addListener&lt;/a&gt; for more </span>
<span class="c">* information on listening for this event.</span>
<span class="c">* @type YAHOO.util.CustomEvent</span>
<span class="c">*/</span>

<span class="o">})();</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div class="module">
                        <h4>Modules</h4>
                        <ul class="content">

                                <li class=""><a href="module_animation.html">animation</a></li>

                                <li class=""><a href="module_autocomplete.html">autocomplete</a></li>

                                <li class="selected"><a href="module_button.html">button</a></li>

                                <li class=""><a href="module_calendar.html">calendar</a></li>

                                <li class=""><a href="module_connection.html">connection</a></li>

                                <li class=""><a href="module_container.html">container</a></li>

                                <li class=""><a href="module_datasource.html">datasource</a></li>

                                <li class=""><a href="module_datatable.html">datatable</a></li>

                                <li class=""><a href="module_dom.html">dom</a></li>

                                <li class=""><a href="module_dragdrop.html">dragdrop</a></li>

                                <li class=""><a href="module_element.html">element</a></li>

                                <li class=""><a href="module_event.html">event</a></li>

                                <li class=""><a href="module_history.html">history</a></li>

                                <li class=""><a href="module_logger.html">logger</a></li>

                                <li class=""><a href="module_menu.html">menu</a></li>

                                <li class=""><a href="module_slider.html">slider</a></li>

                                <li class=""><a href="module_tabview.html">tabview</a></li>

                                <li class=""><a href="module_treeview.html">treeview</a></li>

                                <li class=""><a href="module_yahoo.html">yahoo</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a></li>
                                <li class=""><a href="YAHOO.widget.ButtonGroup.html">YAHOO.widget.ButtonGroup</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class="selected"><a href="button.js.html">button.js</a></li>
                                <li class=""><a href="buttongroup.js.html">buttongroup.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2007 Yahoo! Inc. All rights reserved.
	</div>
</div>
</body>
</html>
